@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function add_downloads_data_filters() { |
68 | 68 | |
69 | - $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
69 | + $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
70 | 70 | |
71 | - if ( ! $downloads_data ) { |
|
71 | + if ( ! $downloads_data ) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function add_admin_menu() { |
99 | 99 | |
100 | - $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
100 | + $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
101 | 101 | |
102 | 102 | $menu_text = sprintf( '<span title="%s" style="margin: 0">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text ); |
103 | 103 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * When on the Installer page, show a different notice than on the Settings page |
|
116 | - * |
|
115 | + * When on the Installer page, show a different notice than on the Settings page |
|
116 | + * |
|
117 | 117 | * @param array $notice |
118 | 118 | * |
119 | 119 | * @return string License notice |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | public function maybe_modify_license_notice( $notice = '' ) { |
122 | 122 | |
123 | 123 | if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) { |
124 | - return $notice; |
|
125 | - } |
|
124 | + return $notice; |
|
125 | + } |
|
126 | 126 | |
127 | - return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
127 | + return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -162,43 +162,43 @@ discard block |
||
162 | 162 | * Get downloads data from transient or from API; save transient after getting data from API |
163 | 163 | * |
164 | 164 | * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: { |
165 | - * @type array $info { |
|
166 | - * @type string $id int 17 |
|
167 | - * @type string $slug Extension slug |
|
168 | - * @type string $title Extension title |
|
169 | - * @type string $create_date in '2018-07-19 20:03:10' format |
|
170 | - * @type string $modified_date |
|
171 | - * @type string $status |
|
172 | - * @type string $link URL to public plugin page |
|
173 | - * @type string $content |
|
174 | - * @type string $excerpt |
|
175 | - * @type string $thumbnail URL to thumbnail |
|
176 | - * @type array $category Taxonomy details for the plugin's category { |
|
177 | - * @type int $term_id => int 30 |
|
178 | - * @type string $name => string 'Plugins' (length=7) |
|
179 | - * @type string $slug => string 'plugins' (length=7) |
|
180 | - * @type int $term_group => int 0 |
|
181 | - * @type int $term_taxonomy_id => int 30 |
|
182 | - * @type string $taxonomy => string 'download_category' (length=17) |
|
183 | - * @type string $description => string '' (length=0) |
|
184 | - * @type int $parent => int 0 |
|
185 | - * @type int $count => int 4 |
|
186 | - * @type string $filter => string 'raw' (length=3) |
|
187 | - * } |
|
188 | - * @type array $tags {see $category above} |
|
189 | - * @type string $textdomain string 'gravityview' (length=11) |
|
190 | - * } |
|
191 | - * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
192 | - * @type array $licensing { |
|
193 | - * @type bool $enabled Is licensing enabled for the extension |
|
194 | - * @type string $version Version number |
|
195 | - * @type string $exp_unit Expiration unit ('years') |
|
196 | - * @type string $exp_length Expiration length ('1') |
|
197 | - * } |
|
198 | - * @type array $files Array of files. Empty if user has no access to the file. { |
|
199 | - * @type string $file string URL of the file download |
|
200 | - * } |
|
201 | - * } |
|
165 | + * @type array $info { |
|
166 | + * @type string $id int 17 |
|
167 | + * @type string $slug Extension slug |
|
168 | + * @type string $title Extension title |
|
169 | + * @type string $create_date in '2018-07-19 20:03:10' format |
|
170 | + * @type string $modified_date |
|
171 | + * @type string $status |
|
172 | + * @type string $link URL to public plugin page |
|
173 | + * @type string $content |
|
174 | + * @type string $excerpt |
|
175 | + * @type string $thumbnail URL to thumbnail |
|
176 | + * @type array $category Taxonomy details for the plugin's category { |
|
177 | + * @type int $term_id => int 30 |
|
178 | + * @type string $name => string 'Plugins' (length=7) |
|
179 | + * @type string $slug => string 'plugins' (length=7) |
|
180 | + * @type int $term_group => int 0 |
|
181 | + * @type int $term_taxonomy_id => int 30 |
|
182 | + * @type string $taxonomy => string 'download_category' (length=17) |
|
183 | + * @type string $description => string '' (length=0) |
|
184 | + * @type int $parent => int 0 |
|
185 | + * @type int $count => int 4 |
|
186 | + * @type string $filter => string 'raw' (length=3) |
|
187 | + * } |
|
188 | + * @type array $tags {see $category above} |
|
189 | + * @type string $textdomain string 'gravityview' (length=11) |
|
190 | + * } |
|
191 | + * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
192 | + * @type array $licensing { |
|
193 | + * @type bool $enabled Is licensing enabled for the extension |
|
194 | + * @type string $version Version number |
|
195 | + * @type string $exp_unit Expiration unit ('years') |
|
196 | + * @type string $exp_length Expiration length ('1') |
|
197 | + * } |
|
198 | + * @type array $files Array of files. Empty if user has no access to the file. { |
|
199 | + * @type string $file string URL of the file download |
|
200 | + * } |
|
201 | + * } |
|
202 | 202 | */ |
203 | 203 | public function get_downloads_data() { |
204 | 204 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ) ); |
231 | 231 | |
232 | 232 | if ( is_wp_error( $response ) ) { |
233 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
233 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
234 | 234 | return $response; |
235 | 235 | } |
236 | 236 | |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | <div class="gv-admin-installer-notice notice inline error"> |
284 | 284 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
285 | 285 | <?php |
286 | - if ( is_wp_error( $downloads_data ) ) { |
|
287 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
288 | - } |
|
289 | - ?> |
|
286 | + if ( is_wp_error( $downloads_data ) ) { |
|
287 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
288 | + } |
|
289 | + ?> |
|
290 | 290 | </div> |
291 | 291 | </div> |
292 | 292 | <?php |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | protected function render_download( $download, $wp_plugins ) { |
343 | 343 | |
344 | 344 | |
345 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
345 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
346 | 346 | |
347 | - $download_info = $details['download_info']; |
|
347 | + $download_info = $details['download_info']; |
|
348 | 348 | |
349 | 349 | ?> |
350 | 350 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -366,43 +366,43 @@ discard block |
||
366 | 366 | |
367 | 367 | <div class="addon-excerpt"><?php |
368 | 368 | |
369 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
369 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
370 | 370 | |
371 | - // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
372 | - $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
373 | - $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
371 | + // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
372 | + $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
373 | + $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
374 | 374 | |
375 | - $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
376 | - $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
375 | + $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
376 | + $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
377 | 377 | $excerpt = str_replace( $replacements, $tags, $excerpt ); |
378 | 378 | |
379 | 379 | echo wpautop( $excerpt ); |
380 | - ?></div> |
|
380 | + ?></div> |
|
381 | 381 | </div> |
382 | 382 | </div> |
383 | 383 | <?php |
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
387 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
388 | - * |
|
387 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
388 | + * |
|
389 | 389 | * @param array $download Single download, as returned by {@see get_downloads_data} |
390 | 390 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
391 | 391 | * |
392 | 392 | * @return array { |
393 | - * @type array $download_info |
|
394 | - * @type string $plugin_path |
|
395 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
396 | - * @type string $status_label |
|
397 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
398 | - * @type string $button_class CSS class to use for the button |
|
399 | - * @type string $button_label Text to use for the download's anchor link |
|
400 | - * @type string $href URL for the download's button |
|
401 | - * @type bool $spinner Whether to show the spinner icon |
|
402 | - * @type string $item_class CSS class for the download container |
|
403 | - * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
404 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
405 | - * } |
|
393 | + * @type array $download_info |
|
394 | + * @type string $plugin_path |
|
395 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
396 | + * @type string $status_label |
|
397 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
398 | + * @type string $button_class CSS class to use for the button |
|
399 | + * @type string $button_label Text to use for the download's anchor link |
|
400 | + * @type string $href URL for the download's button |
|
401 | + * @type bool $spinner Whether to show the spinner icon |
|
402 | + * @type string $item_class CSS class for the download container |
|
403 | + * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
404 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
405 | + * } |
|
406 | 406 | */ |
407 | 407 | private function get_download_display_details( $download, $wp_plugins ) { |
408 | 408 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | 'slug' => '', |
414 | 414 | 'excerpt' => '', |
415 | 415 | 'link' => '', |
416 | - 'coming_soon' => false, |
|
416 | + 'coming_soon' => false, |
|
417 | 417 | 'installer_title' => null, // May not be defined |
418 | 418 | 'installer_excerpt' => null, // May not be defined |
419 | 419 | ) ); |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
457 | 457 | } |
458 | 458 | |
459 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
460 | - $spinner = false; |
|
461 | - $status = 'notinstalled'; |
|
462 | - $status_label = __( 'Coming Soon', 'gravityview' ); |
|
463 | - $button_label = __( 'Learn More', 'gravityview' ); |
|
464 | - $button_class = 'button-primary button-large'; |
|
465 | - $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
466 | - } |
|
459 | + elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
460 | + $spinner = false; |
|
461 | + $status = 'notinstalled'; |
|
462 | + $status_label = __( 'Coming Soon', 'gravityview' ); |
|
463 | + $button_label = __( 'Learn More', 'gravityview' ); |
|
464 | + $button_class = 'button-primary button-large'; |
|
465 | + $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
466 | + } |
|
467 | 467 | |
468 | 468 | // Access but the plugin is not installed |
469 | 469 | elseif ( ! $wp_plugin ) { |
@@ -503,18 +503,18 @@ discard block |
||
503 | 503 | } |
504 | 504 | |
505 | 505 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
506 | - } |
|
506 | + } |
|
507 | 507 | |
508 | 508 | /** |
509 | - * Returns the base price for an extension |
|
510 | - * |
|
509 | + * Returns the base price for an extension |
|
510 | + * |
|
511 | 511 | * @param array $download |
512 | 512 | * |
513 | 513 | * @return float Base price for an extension. If not for sale separately, returns 0 |
514 | 514 | */ |
515 | 515 | private function get_download_base_price( $download ) { |
516 | 516 | |
517 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
517 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
518 | 518 | $base_price = \GFCommon::to_number( $base_price ); |
519 | 519 | |
520 | 520 | unset( $download['pricing']['amount'] ); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | } |
526 | 526 | |
527 | 527 | return floatval( $base_price ); |
528 | - } |
|
528 | + } |
|
529 | 529 | |
530 | 530 | /** |
531 | 531 | * Handle AJAX request to activate extension |
@@ -543,8 +543,8 @@ discard block |
||
543 | 543 | |
544 | 544 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
545 | 545 | wp_send_json_error( array( |
546 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
547 | - ) ); |
|
546 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
547 | + ) ); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | wp_send_json_success(); |
@@ -565,10 +565,10 @@ discard block |
||
565 | 565 | deactivate_plugins( $data['path'] ); |
566 | 566 | |
567 | 567 | if( is_plugin_active( $data['path'] ) ) { |
568 | - wp_send_json_error( array( |
|
569 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
570 | - ) ); |
|
571 | - } |
|
568 | + wp_send_json_error( array( |
|
569 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
570 | + ) ); |
|
571 | + } |
|
572 | 572 | |
573 | 573 | wp_send_json_success(); |
574 | 574 | } |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | |
103 | 103 | /** |
104 | 104 | * ID of the current post. May also be ID of the current View. |
105 | - * |
|
106 | - * @since 2.0.13 |
|
107 | 105 | * |
108 | - * @var int |
|
106 | + * @since 2.0.13 |
|
107 | + * |
|
108 | + * @var int |
|
109 | 109 | */ |
110 | 110 | public $post_id; |
111 | 111 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function prevent_maybe_process_form() { |
190 | 190 | |
191 | - if( ! $this->is_edit_entry_submission() ) { |
|
191 | + if( ! $this->is_edit_entry_submission() ) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
@@ -222,14 +222,14 @@ discard block |
||
222 | 222 | * When Edit entry view is requested setup the vars |
223 | 223 | */ |
224 | 224 | private function setup_vars() { |
225 | - global $post; |
|
225 | + global $post; |
|
226 | 226 | |
227 | 227 | $gravityview_view = GravityView_View::getInstance(); |
228 | 228 | |
229 | 229 | |
230 | 230 | $entries = $gravityview_view->getEntries(); |
231 | - self::$original_entry = $entries[0]; |
|
232 | - $this->entry = $entries[0]; |
|
231 | + self::$original_entry = $entries[0]; |
|
232 | + $this->entry = $entries[0]; |
|
233 | 233 | |
234 | 234 | self::$original_form = $gravityview_view->getForm(); |
235 | 235 | $this->form = $gravityview_view->getForm(); |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | |
372 | 372 | GFFormsModel::save_lead( $form, $this->entry ); |
373 | 373 | |
374 | - // Delete the values for hidden inputs |
|
375 | - $this->unset_hidden_field_values(); |
|
374 | + // Delete the values for hidden inputs |
|
375 | + $this->unset_hidden_field_values(); |
|
376 | 376 | |
377 | 377 | $this->entry['date_created'] = $date_created; |
378 | 378 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | // Perform actions normally performed after updating a lead |
386 | 386 | $this->after_update(); |
387 | 387 | |
388 | - /** |
|
388 | + /** |
|
389 | 389 | * Must be AFTER after_update()! |
390 | 390 | * @see https://github.com/gravityview/GravityView/issues/764 |
391 | 391 | */ |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
396 | - * @since 2.1 Added $gv_data parameter |
|
396 | + * @since 2.1 Added $gv_data parameter |
|
397 | 397 | * @param array $form Gravity Forms form array |
398 | 398 | * @param string $entry_id Numeric ID of the entry that was updated |
399 | 399 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @return void |
418 | 418 | */ |
419 | 419 | private function unset_hidden_field_values() { |
420 | - global $wpdb; |
|
420 | + global $wpdb; |
|
421 | 421 | |
422 | 422 | /** |
423 | 423 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
442 | 442 | } |
443 | 443 | |
444 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
444 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
445 | 445 | |
446 | 446 | if ( ! is_numeric( $input_id ) ) { |
447 | 447 | continue; |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | continue; |
452 | 452 | } |
453 | 453 | |
454 | - // Reset fields that are or would be hidden |
|
455 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
454 | + // Reset fields that are or would be hidden |
|
455 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
456 | 456 | |
457 | 457 | $empty_value = $field->get_value_save_entry( |
458 | 458 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -464,16 +464,16 @@ discard block |
||
464 | 464 | $empty_value = ''; |
465 | 465 | } |
466 | 466 | |
467 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
467 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
468 | 468 | |
469 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
469 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
470 | 470 | |
471 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
471 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
472 | 472 | // after submission |
473 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
474 | - $_POST[ $post_input_id ] = ''; |
|
475 | - } |
|
476 | - } |
|
473 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
474 | + $_POST[ $post_input_id ] = ''; |
|
475 | + } |
|
476 | + } |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | |
629 | 629 | $form = $this->filter_conditional_logic( $this->form ); |
630 | 630 | |
631 | - /** @var GF_Field $field */ |
|
631 | + /** @var GF_Field $field */ |
|
632 | 632 | foreach( $form['fields'] as $k => &$field ) { |
633 | 633 | |
634 | 634 | /** |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
646 | 646 | foreach( $field->inputs as $key => $input ) { |
647 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
647 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | |
685 | 685 | $inputs = $field->get_entry_inputs(); |
686 | 686 | if ( is_array( $inputs ) ) { |
687 | - foreach ( $inputs as $input ) { |
|
687 | + foreach ( $inputs as $input ) { |
|
688 | 688 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
689 | 689 | |
690 | 690 | if ( 'product' === $field->type ) { |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | } |
704 | 704 | |
705 | 705 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
706 | - } |
|
706 | + } |
|
707 | 707 | } else { |
708 | 708 | // Set to what it previously was if it's not editable |
709 | 709 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
750 | 750 | |
751 | 751 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
752 | - $ary = stripslashes_deep( $ary ); |
|
752 | + $ary = stripslashes_deep( $ary ); |
|
753 | 753 | $img_url = \GV\Utils::get( $ary, 0 ); |
754 | 754 | |
755 | 755 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | private function maybe_update_post_fields( $form ) { |
823 | 823 | |
824 | 824 | if( empty( $this->entry['post_id'] ) ) { |
825 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
825 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
826 | 826 | return; |
827 | 827 | } |
828 | 828 | |
@@ -857,49 +857,49 @@ discard block |
||
857 | 857 | |
858 | 858 | switch( $field->type ) { |
859 | 859 | |
860 | - case 'post_title': |
|
861 | - $post_title = $value; |
|
862 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
863 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
864 | - } |
|
865 | - $updated_post->post_title = $post_title; |
|
866 | - $updated_post->post_name = $post_title; |
|
867 | - unset( $post_title ); |
|
868 | - break; |
|
869 | - |
|
870 | - case 'post_content': |
|
871 | - $post_content = $value; |
|
872 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
873 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
874 | - } |
|
875 | - $updated_post->post_content = $post_content; |
|
876 | - unset( $post_content ); |
|
877 | - break; |
|
878 | - case 'post_excerpt': |
|
879 | - $updated_post->post_excerpt = $value; |
|
880 | - break; |
|
881 | - case 'post_tags': |
|
882 | - wp_set_post_tags( $post_id, $value, false ); |
|
883 | - break; |
|
884 | - case 'post_category': |
|
885 | - break; |
|
886 | - case 'post_custom_field': |
|
860 | + case 'post_title': |
|
861 | + $post_title = $value; |
|
862 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
863 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
864 | + } |
|
865 | + $updated_post->post_title = $post_title; |
|
866 | + $updated_post->post_name = $post_title; |
|
867 | + unset( $post_title ); |
|
868 | + break; |
|
869 | + |
|
870 | + case 'post_content': |
|
871 | + $post_content = $value; |
|
872 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
873 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
874 | + } |
|
875 | + $updated_post->post_content = $post_content; |
|
876 | + unset( $post_content ); |
|
877 | + break; |
|
878 | + case 'post_excerpt': |
|
879 | + $updated_post->post_excerpt = $value; |
|
880 | + break; |
|
881 | + case 'post_tags': |
|
882 | + wp_set_post_tags( $post_id, $value, false ); |
|
883 | + break; |
|
884 | + case 'post_category': |
|
885 | + break; |
|
886 | + case 'post_custom_field': |
|
887 | 887 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
888 | 888 | $value = $value[ $field_id ]; |
889 | 889 | } |
890 | 890 | |
891 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
892 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
893 | - } |
|
891 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
892 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
893 | + } |
|
894 | 894 | |
895 | 895 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
896 | 896 | |
897 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
898 | - break; |
|
897 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
898 | + break; |
|
899 | 899 | |
900 | - case 'post_image': |
|
901 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
902 | - break; |
|
900 | + case 'post_image': |
|
901 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
902 | + break; |
|
903 | 903 | |
904 | 904 | } |
905 | 905 | |
@@ -1063,14 +1063,14 @@ discard block |
||
1063 | 1063 | ?><h2 class="gv-edit-entry-title"> |
1064 | 1064 | <span><?php |
1065 | 1065 | |
1066 | - /** |
|
1067 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1068 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1069 | - * @param GravityView_Edit_Entry_Render $this This object |
|
1070 | - */ |
|
1071 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1066 | + /** |
|
1067 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1068 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1069 | + * @param GravityView_Edit_Entry_Render $this This object |
|
1070 | + */ |
|
1071 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1072 | 1072 | |
1073 | - echo esc_attr( $edit_entry_title ); |
|
1073 | + echo esc_attr( $edit_entry_title ); |
|
1074 | 1074 | ?></span> |
1075 | 1075 | </h2> |
1076 | 1076 | |
@@ -1125,13 +1125,13 @@ discard block |
||
1125 | 1125 | ); |
1126 | 1126 | |
1127 | 1127 | /** |
1128 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1129 | - * @since 1.16.3 |
|
1130 | - * @param array $labels Default button labels associative array |
|
1131 | - * @param array $form The Gravity Forms form |
|
1132 | - * @param array $entry The Gravity Forms entry |
|
1133 | - * @param int $view_id The current View ID |
|
1134 | - */ |
|
1128 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1129 | + * @since 1.16.3 |
|
1130 | + * @param array $labels Default button labels associative array |
|
1131 | + * @param array $form The Gravity Forms form |
|
1132 | + * @param array $entry The Gravity Forms entry |
|
1133 | + * @param int $view_id The current View ID |
|
1134 | + */ |
|
1135 | 1135 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1136 | 1136 | |
1137 | 1137 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1168,26 +1168,26 @@ discard block |
||
1168 | 1168 | |
1169 | 1169 | switch ( $edit_redirect ) { |
1170 | 1170 | |
1171 | - case '0': |
|
1172 | - $redirect_url = $back_link; |
|
1173 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1174 | - break; |
|
1175 | - |
|
1176 | - case '1': |
|
1177 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1178 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1179 | - break; |
|
1180 | - |
|
1181 | - case '2': |
|
1182 | - $redirect_url = $edit_redirect_url; |
|
1183 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1184 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1185 | - break; |
|
1186 | - |
|
1187 | - case '': |
|
1188 | - default: |
|
1189 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1190 | - break; |
|
1171 | + case '0': |
|
1172 | + $redirect_url = $back_link; |
|
1173 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1174 | + break; |
|
1175 | + |
|
1176 | + case '1': |
|
1177 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1178 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1179 | + break; |
|
1180 | + |
|
1181 | + case '2': |
|
1182 | + $redirect_url = $edit_redirect_url; |
|
1183 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1184 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1185 | + break; |
|
1186 | + |
|
1187 | + case '': |
|
1188 | + default: |
|
1189 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1190 | + break; |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | if ( isset( $redirect_url ) ) { |
@@ -1253,13 +1253,13 @@ discard block |
||
1253 | 1253 | ); |
1254 | 1254 | |
1255 | 1255 | /** |
1256 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1257 | - * @since 1.16.3 |
|
1258 | - * @param array $labels Default button labels associative array |
|
1259 | - * @param array $form The Gravity Forms form |
|
1260 | - * @param array $entry The Gravity Forms entry |
|
1261 | - * @param int $view_id The current View ID |
|
1262 | - */ |
|
1256 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1257 | + * @since 1.16.3 |
|
1258 | + * @param array $labels Default button labels associative array |
|
1259 | + * @param array $form The Gravity Forms form |
|
1260 | + * @param array $entry The Gravity Forms entry |
|
1261 | + * @param int $view_id The current View ID |
|
1262 | + */ |
|
1263 | 1263 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1264 | 1264 | |
1265 | 1265 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | |
1306 | 1306 | ob_get_clean(); |
1307 | 1307 | |
1308 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1308 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1309 | 1309 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1310 | 1310 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1311 | 1311 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | |
1366 | 1366 | // for now we don't support Save and Continue feature. |
1367 | 1367 | if( ! self::$supports_save_and_continue ) { |
1368 | - unset( $form['save'] ); |
|
1368 | + unset( $form['save'] ); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | $form = $this->unselect_default_values( $form ); |
@@ -1392,30 +1392,30 @@ discard block |
||
1392 | 1392 | return $field_content; |
1393 | 1393 | } |
1394 | 1394 | |
1395 | - $message = null; |
|
1395 | + $message = null; |
|
1396 | 1396 | |
1397 | - // First, make sure they have the capability to edit the post. |
|
1398 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1397 | + // First, make sure they have the capability to edit the post. |
|
1398 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1399 | 1399 | |
1400 | - /** |
|
1401 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1402 | - * @param string $message The existing "You don't have permission..." text |
|
1403 | - */ |
|
1404 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1400 | + /** |
|
1401 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1402 | + * @param string $message The existing "You don't have permission..." text |
|
1403 | + */ |
|
1404 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1405 | 1405 | |
1406 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1407 | - /** |
|
1408 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1409 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1410 | - */ |
|
1411 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1412 | - } |
|
1406 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1407 | + /** |
|
1408 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1409 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1410 | + */ |
|
1411 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1412 | + } |
|
1413 | 1413 | |
1414 | - if( $message ) { |
|
1415 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1416 | - } |
|
1414 | + if( $message ) { |
|
1415 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1416 | + } |
|
1417 | 1417 | |
1418 | - return $field_content; |
|
1418 | + return $field_content; |
|
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | /** |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | || ! empty( $field_content ) |
1444 | 1444 | || in_array( $field->type, array( 'honeypot' ) ) |
1445 | 1445 | ) { |
1446 | - return $field_content; |
|
1446 | + return $field_content; |
|
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1451,24 +1451,24 @@ discard block |
||
1451 | 1451 | |
1452 | 1452 | $field_value = $this->get_field_value( $field ); |
1453 | 1453 | |
1454 | - // Prevent any PHP warnings, like undefined index |
|
1455 | - ob_start(); |
|
1454 | + // Prevent any PHP warnings, like undefined index |
|
1455 | + ob_start(); |
|
1456 | 1456 | |
1457 | - $return = null; |
|
1457 | + $return = null; |
|
1458 | 1458 | |
1459 | 1459 | /** @var GravityView_Field $gv_field */ |
1460 | 1460 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1461 | 1461 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1462 | 1462 | } else { |
1463 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1464 | - } |
|
1463 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1464 | + } |
|
1465 | 1465 | |
1466 | - // If there was output, it's an error |
|
1467 | - $warnings = ob_get_clean(); |
|
1466 | + // If there was output, it's an error |
|
1467 | + $warnings = ob_get_clean(); |
|
1468 | 1468 | |
1469 | - if( !empty( $warnings ) ) { |
|
1470 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1471 | - } |
|
1469 | + if( !empty( $warnings ) ) { |
|
1470 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1471 | + } |
|
1472 | 1472 | |
1473 | 1473 | return $return; |
1474 | 1474 | } |
@@ -1503,8 +1503,8 @@ discard block |
||
1503 | 1503 | $input_id = strval( $input['id'] ); |
1504 | 1504 | |
1505 | 1505 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1506 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1507 | - $allow_pre_populated = false; |
|
1506 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1507 | + $allow_pre_populated = false; |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | } |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1529 | 1529 | $categories = array(); |
1530 | 1530 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1531 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1531 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1532 | 1532 | } |
1533 | 1533 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1534 | 1534 | } |
@@ -1538,25 +1538,25 @@ discard block |
||
1538 | 1538 | // if value is empty get the default value if defined |
1539 | 1539 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1540 | 1540 | |
1541 | - /** |
|
1542 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1543 | - * @since 1.11 |
|
1544 | - * @since 1.20 Added third param |
|
1545 | - * @param mixed $field_value field value used to populate the input |
|
1546 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1547 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1548 | - */ |
|
1549 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1550 | - |
|
1551 | - /** |
|
1552 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1553 | - * @since 1.17 |
|
1554 | - * @since 1.20 Added third param |
|
1555 | - * @param mixed $field_value field value used to populate the input |
|
1556 | - * @param GF_Field $field Gravity Forms field object |
|
1557 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1558 | - */ |
|
1559 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1541 | + /** |
|
1542 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1543 | + * @since 1.11 |
|
1544 | + * @since 1.20 Added third param |
|
1545 | + * @param mixed $field_value field value used to populate the input |
|
1546 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1547 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1548 | + */ |
|
1549 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1550 | + |
|
1551 | + /** |
|
1552 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1553 | + * @since 1.17 |
|
1554 | + * @since 1.20 Added third param |
|
1555 | + * @param mixed $field_value field value used to populate the input |
|
1556 | + * @param GF_Field $field Gravity Forms field object |
|
1557 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1558 | + */ |
|
1559 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1560 | 1560 | |
1561 | 1561 | return $field_value; |
1562 | 1562 | } |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1584 | 1584 | // expects certain field array items to be set. |
1585 | 1585 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1586 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1586 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1597,61 +1597,61 @@ discard block |
||
1597 | 1597 | */ |
1598 | 1598 | case 'fileupload': |
1599 | 1599 | |
1600 | - // Set the previous value |
|
1601 | - $entry = $this->get_entry(); |
|
1600 | + // Set the previous value |
|
1601 | + $entry = $this->get_entry(); |
|
1602 | 1602 | |
1603 | - $input_name = 'input_'.$field->id; |
|
1604 | - $form_id = $form['id']; |
|
1603 | + $input_name = 'input_'.$field->id; |
|
1604 | + $form_id = $form['id']; |
|
1605 | 1605 | |
1606 | - $value = NULL; |
|
1606 | + $value = NULL; |
|
1607 | 1607 | |
1608 | - // Use the previous entry value as the default. |
|
1609 | - if( isset( $entry[ $field->id ] ) ) { |
|
1610 | - $value = $entry[ $field->id ]; |
|
1611 | - } |
|
1608 | + // Use the previous entry value as the default. |
|
1609 | + if( isset( $entry[ $field->id ] ) ) { |
|
1610 | + $value = $entry[ $field->id ]; |
|
1611 | + } |
|
1612 | 1612 | |
1613 | - // If this is a single upload file |
|
1614 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1615 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1616 | - $value = $file_path['url']; |
|
1613 | + // If this is a single upload file |
|
1614 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1615 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1616 | + $value = $file_path['url']; |
|
1617 | 1617 | |
1618 | - } else { |
|
1618 | + } else { |
|
1619 | 1619 | |
1620 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1621 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1622 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1620 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1621 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1622 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1623 | 1623 | |
1624 | - } |
|
1624 | + } |
|
1625 | 1625 | |
1626 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1626 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1627 | 1627 | |
1628 | - // If there are fresh uploads, process and merge them. |
|
1629 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1630 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1631 | - $value = empty( $value ) ? '[]' : $value; |
|
1632 | - $value = stripslashes_deep( $value ); |
|
1633 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1634 | - } |
|
1628 | + // If there are fresh uploads, process and merge them. |
|
1629 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1630 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1631 | + $value = empty( $value ) ? '[]' : $value; |
|
1632 | + $value = stripslashes_deep( $value ); |
|
1633 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1634 | + } |
|
1635 | 1635 | |
1636 | - } else { |
|
1636 | + } else { |
|
1637 | 1637 | |
1638 | - // A file already exists when editing an entry |
|
1639 | - // We set this to solve issue when file upload fields are required. |
|
1640 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1638 | + // A file already exists when editing an entry |
|
1639 | + // We set this to solve issue when file upload fields are required. |
|
1640 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1641 | 1641 | |
1642 | - } |
|
1642 | + } |
|
1643 | 1643 | |
1644 | - $this->entry[ $input_name ] = $value; |
|
1645 | - $_POST[ $input_name ] = $value; |
|
1644 | + $this->entry[ $input_name ] = $value; |
|
1645 | + $_POST[ $input_name ] = $value; |
|
1646 | 1646 | |
1647 | - break; |
|
1647 | + break; |
|
1648 | 1648 | |
1649 | 1649 | case 'number': |
1650 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1651 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1652 | - $_POST['input_'.$field->id ] = NULL; |
|
1653 | - } |
|
1654 | - break; |
|
1650 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1651 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1652 | + $_POST['input_'.$field->id ] = NULL; |
|
1653 | + } |
|
1654 | + break; |
|
1655 | 1655 | } |
1656 | 1656 | |
1657 | 1657 | } |
@@ -1736,43 +1736,43 @@ discard block |
||
1736 | 1736 | case 'fileupload' : |
1737 | 1737 | case 'post_image': |
1738 | 1738 | |
1739 | - // in case nothing is uploaded but there are already files saved |
|
1740 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1741 | - $field->failed_validation = false; |
|
1742 | - unset( $field->validation_message ); |
|
1743 | - } |
|
1739 | + // in case nothing is uploaded but there are already files saved |
|
1740 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1741 | + $field->failed_validation = false; |
|
1742 | + unset( $field->validation_message ); |
|
1743 | + } |
|
1744 | 1744 | |
1745 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1746 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1745 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1746 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1747 | 1747 | |
1748 | - $input_name = 'input_' . $field->id; |
|
1749 | - //uploaded |
|
1750 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1748 | + $input_name = 'input_' . $field->id; |
|
1749 | + //uploaded |
|
1750 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1751 | 1751 | |
1752 | - //existent |
|
1753 | - $entry = $this->get_entry(); |
|
1754 | - $value = NULL; |
|
1755 | - if( isset( $entry[ $field->id ] ) ) { |
|
1756 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1757 | - } |
|
1752 | + //existent |
|
1753 | + $entry = $this->get_entry(); |
|
1754 | + $value = NULL; |
|
1755 | + if( isset( $entry[ $field->id ] ) ) { |
|
1756 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1757 | + } |
|
1758 | 1758 | |
1759 | - // count uploaded files and existent entry files |
|
1760 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1761 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1759 | + // count uploaded files and existent entry files |
|
1760 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1761 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1762 | 1762 | |
1763 | - if( $count_files > $field->maxFiles ) { |
|
1764 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1765 | - $field->failed_validation = 1; |
|
1766 | - $gv_valid = false; |
|
1763 | + if( $count_files > $field->maxFiles ) { |
|
1764 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1765 | + $field->failed_validation = 1; |
|
1766 | + $gv_valid = false; |
|
1767 | 1767 | |
1768 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1769 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1770 | - } |
|
1768 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1769 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1770 | + } |
|
1771 | 1771 | |
1772 | - } |
|
1772 | + } |
|
1773 | 1773 | |
1774 | 1774 | |
1775 | - break; |
|
1775 | + break; |
|
1776 | 1776 | |
1777 | 1777 | } |
1778 | 1778 | |
@@ -1783,47 +1783,47 @@ discard block |
||
1783 | 1783 | |
1784 | 1784 | switch ( $field_type ) { |
1785 | 1785 | |
1786 | - // Captchas don't need to be re-entered. |
|
1787 | - case 'captcha': |
|
1786 | + // Captchas don't need to be re-entered. |
|
1787 | + case 'captcha': |
|
1788 | 1788 | |
1789 | - // Post Image fields aren't editable, so we un-fail them. |
|
1790 | - case 'post_image': |
|
1791 | - $field->failed_validation = false; |
|
1792 | - unset( $field->validation_message ); |
|
1793 | - break; |
|
1789 | + // Post Image fields aren't editable, so we un-fail them. |
|
1790 | + case 'post_image': |
|
1791 | + $field->failed_validation = false; |
|
1792 | + unset( $field->validation_message ); |
|
1793 | + break; |
|
1794 | 1794 | |
1795 | 1795 | } |
1796 | 1796 | |
1797 | 1797 | // You can't continue inside a switch, so we do it after. |
1798 | 1798 | if( empty( $field->failed_validation ) ) { |
1799 | - continue; |
|
1799 | + continue; |
|
1800 | 1800 | } |
1801 | 1801 | |
1802 | 1802 | // checks if the No Duplicates option is not validating entry against itself, since |
1803 | 1803 | // we're editing a stored entry, it would also assume it's a duplicate. |
1804 | 1804 | if( !empty( $field->noDuplicates ) ) { |
1805 | 1805 | |
1806 | - $entry = $this->get_entry(); |
|
1806 | + $entry = $this->get_entry(); |
|
1807 | 1807 | |
1808 | - // If the value of the entry is the same as the stored value |
|
1809 | - // Then we can assume it's not a duplicate, it's the same. |
|
1810 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1811 | - //if value submitted was not changed, then don't validate |
|
1812 | - $field->failed_validation = false; |
|
1808 | + // If the value of the entry is the same as the stored value |
|
1809 | + // Then we can assume it's not a duplicate, it's the same. |
|
1810 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1811 | + //if value submitted was not changed, then don't validate |
|
1812 | + $field->failed_validation = false; |
|
1813 | 1813 | |
1814 | - unset( $field->validation_message ); |
|
1814 | + unset( $field->validation_message ); |
|
1815 | 1815 | |
1816 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1816 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1817 | 1817 | |
1818 | - continue; |
|
1819 | - } |
|
1818 | + continue; |
|
1819 | + } |
|
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1823 | 1823 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1824 | - unset( $field->validation_message ); |
|
1825 | - $field->validation_message = false; |
|
1826 | - continue; |
|
1824 | + unset( $field->validation_message ); |
|
1825 | + $field->validation_message = false; |
|
1826 | + continue; |
|
1827 | 1827 | } |
1828 | 1828 | |
1829 | 1829 | $gv_valid = false; |
@@ -1887,8 +1887,8 @@ discard block |
||
1887 | 1887 | // Hide fields depending on admin settings |
1888 | 1888 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1889 | 1889 | |
1890 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1891 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1890 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1891 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1892 | 1892 | |
1893 | 1893 | /** |
1894 | 1894 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1967,11 +1967,11 @@ discard block |
||
1967 | 1967 | // The edit tab has been configured, so we loop through to configured settings |
1968 | 1968 | foreach ( $configured_fields as $configured_field ) { |
1969 | 1969 | |
1970 | - /** @var GF_Field $field */ |
|
1971 | - foreach ( $fields as $field ) { |
|
1970 | + /** @var GF_Field $field */ |
|
1971 | + foreach ( $fields as $field ) { |
|
1972 | 1972 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1973 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1974 | - break; |
|
1973 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1974 | + break; |
|
1975 | 1975 | } |
1976 | 1976 | |
1977 | 1977 | } |
@@ -2027,28 +2027,28 @@ discard block |
||
2027 | 2027 | */ |
2028 | 2028 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
2029 | 2029 | |
2030 | - /** |
|
2030 | + /** |
|
2031 | 2031 | * @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 |
2032 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2033 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2034 | - * @since 1.9.1 |
|
2035 | - * @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. |
|
2036 | - * @param array $form GF Form array |
|
2037 | - * @param int $view_id View ID |
|
2038 | - */ |
|
2039 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2040 | - |
|
2041 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2032 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2033 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2034 | + * @since 1.9.1 |
|
2035 | + * @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. |
|
2036 | + * @param array $form GF Form array |
|
2037 | + * @param int $view_id View ID |
|
2038 | + */ |
|
2039 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2040 | + |
|
2041 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2042 | 2042 | foreach( $fields as $k => $field ) { |
2043 | 2043 | if( $field->adminOnly ) { |
2044 | - unset( $fields[ $k ] ); |
|
2044 | + unset( $fields[ $k ] ); |
|
2045 | 2045 | } |
2046 | 2046 | } |
2047 | 2047 | return array_values( $fields ); |
2048 | 2048 | } |
2049 | 2049 | |
2050 | - foreach( $fields as &$field ) { |
|
2051 | - $field->adminOnly = false; |
|
2050 | + foreach( $fields as &$field ) { |
|
2051 | + $field->adminOnly = false; |
|
2052 | 2052 | } |
2053 | 2053 | |
2054 | 2054 | return $fields; |
@@ -2068,13 +2068,13 @@ discard block |
||
2068 | 2068 | */ |
2069 | 2069 | private function unselect_default_values( $form ) { |
2070 | 2070 | |
2071 | - foreach ( $form['fields'] as &$field ) { |
|
2071 | + foreach ( $form['fields'] as &$field ) { |
|
2072 | 2072 | |
2073 | 2073 | if ( empty( $field->choices ) ) { |
2074 | - continue; |
|
2074 | + continue; |
|
2075 | 2075 | } |
2076 | 2076 | |
2077 | - foreach ( $field->choices as &$choice ) { |
|
2077 | + foreach ( $field->choices as &$choice ) { |
|
2078 | 2078 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2079 | 2079 | $choice['isSelected'] = false; |
2080 | 2080 | } |
@@ -2111,36 +2111,36 @@ discard block |
||
2111 | 2111 | |
2112 | 2112 | if( 'checkbox' === $field->type ) { |
2113 | 2113 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2114 | - $input_id = $input['id']; |
|
2115 | - $choice = $field->choices[ $key ]; |
|
2116 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2117 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2118 | - if( $match ) { |
|
2119 | - $field->choices[ $key ]['isSelected'] = true; |
|
2120 | - } |
|
2114 | + $input_id = $input['id']; |
|
2115 | + $choice = $field->choices[ $key ]; |
|
2116 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2117 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2118 | + if( $match ) { |
|
2119 | + $field->choices[ $key ]['isSelected'] = true; |
|
2120 | + } |
|
2121 | 2121 | } |
2122 | 2122 | } else { |
2123 | 2123 | |
2124 | 2124 | // We need to run through each field to set the default values |
2125 | 2125 | foreach ( $this->entry as $field_id => $field_value ) { |
2126 | 2126 | |
2127 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2127 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2128 | 2128 | |
2129 | - if( 'list' === $field->type ) { |
|
2130 | - $list_rows = maybe_unserialize( $field_value ); |
|
2129 | + if( 'list' === $field->type ) { |
|
2130 | + $list_rows = maybe_unserialize( $field_value ); |
|
2131 | 2131 | |
2132 | - $list_field_value = array(); |
|
2133 | - foreach ( (array) $list_rows as $row ) { |
|
2134 | - foreach ( (array) $row as $column ) { |
|
2135 | - $list_field_value[] = $column; |
|
2136 | - } |
|
2137 | - } |
|
2132 | + $list_field_value = array(); |
|
2133 | + foreach ( (array) $list_rows as $row ) { |
|
2134 | + foreach ( (array) $row as $column ) { |
|
2135 | + $list_field_value[] = $column; |
|
2136 | + } |
|
2137 | + } |
|
2138 | 2138 | |
2139 | - $field->defaultValue = serialize( $list_field_value ); |
|
2140 | - } else { |
|
2141 | - $field->defaultValue = $field_value; |
|
2142 | - } |
|
2143 | - } |
|
2139 | + $field->defaultValue = serialize( $list_field_value ); |
|
2140 | + } else { |
|
2141 | + $field->defaultValue = $field_value; |
|
2142 | + } |
|
2143 | + } |
|
2144 | 2144 | } |
2145 | 2145 | } |
2146 | 2146 | } |
@@ -2201,7 +2201,7 @@ discard block |
||
2201 | 2201 | foreach ( $form['fields'] as &$field ) { |
2202 | 2202 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2203 | 2203 | |
2204 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2204 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2205 | 2205 | |
2206 | 2206 | if ( $field['id'] == $rule_field_id ) { |
2207 | 2207 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2252,7 +2252,7 @@ discard block |
||
2252 | 2252 | return $has_conditional_logic; |
2253 | 2253 | } |
2254 | 2254 | |
2255 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2255 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2256 | 2256 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2257 | 2257 | } |
2258 | 2258 | |
@@ -2319,14 +2319,14 @@ discard block |
||
2319 | 2319 | |
2320 | 2320 | if( $echo && $error !== true ) { |
2321 | 2321 | |
2322 | - $error = esc_html( $error ); |
|
2322 | + $error = esc_html( $error ); |
|
2323 | 2323 | |
2324 | - /** |
|
2325 | - * @since 1.9 |
|
2326 | - */ |
|
2327 | - if ( ! empty( $this->entry ) ) { |
|
2328 | - $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;" ) ); |
|
2329 | - } |
|
2324 | + /** |
|
2325 | + * @since 1.9 |
|
2326 | + */ |
|
2327 | + if ( ! empty( $this->entry ) ) { |
|
2328 | + $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;" ) ); |
|
2329 | + } |
|
2330 | 2330 | |
2331 | 2331 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2332 | 2332 | } |
@@ -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 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | |
176 | 176 | if( 'form_list' === GFForms::get_page() ) { |
177 | 177 | $priority = 790; |
178 | - } |
|
178 | + } |
|
179 | 179 | |
180 | 180 | if( empty( $connected_views ) ) { |
181 | 181 | |
182 | - $menu_items['gravityview'] = array( |
|
182 | + $menu_items['gravityview'] = array( |
|
183 | 183 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
184 | 184 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
185 | 185 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | // If there were no items added, then let's create the parent menu |
211 | 211 | if( $sub_menu_items ) { |
212 | 212 | |
213 | - $sub_menu_items[] = array( |
|
214 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
215 | - 'link_class' => 'gv-create-view', |
|
216 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
217 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
218 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
219 | - ); |
|
213 | + $sub_menu_items[] = array( |
|
214 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
215 | + 'link_class' => 'gv-create-view', |
|
216 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
217 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
218 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
219 | + ); |
|
220 | 220 | |
221 | 221 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
222 | 222 | $sub_menu_items[] = array( |
@@ -599,12 +599,12 @@ discard block |
||
599 | 599 | * Render html for displaying available fields based on a Form ID |
600 | 600 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
601 | 601 | * |
602 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
602 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
603 | 603 | * @access public |
604 | - * |
|
604 | + * |
|
605 | 605 | * @param int $form Gravity Forms Form ID (default: '') |
606 | 606 | * @param string $context (default: 'single') |
607 | - * |
|
607 | + * |
|
608 | 608 | * @return void |
609 | 609 | */ |
610 | 610 | function render_available_fields( $form = 0, $context = 'single' ) { |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | if ( ! is_array( $blacklist_field_types ) ) { |
620 | 620 | |
621 | - gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
621 | + gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
622 | 622 | |
623 | 623 | $blacklist_field_types = array(); |
624 | 624 | } |
@@ -750,12 +750,12 @@ discard block |
||
750 | 750 | /** |
751 | 751 | * @since 1.7.2 |
752 | 752 | */ |
753 | - 'other_entries' => array( |
|
754 | - 'label' => __('Other Entries', 'gravityview'), |
|
755 | - 'type' => 'other_entries', |
|
756 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
757 | - ), |
|
758 | - ); |
|
753 | + 'other_entries' => array( |
|
754 | + 'label' => __('Other Entries', 'gravityview'), |
|
755 | + 'type' => 'other_entries', |
|
756 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
757 | + ), |
|
758 | + ); |
|
759 | 759 | |
760 | 760 | if( 'single' !== $zone) { |
761 | 761 | |
@@ -903,9 +903,9 @@ discard block |
||
903 | 903 | |
904 | 904 | $joined_forms = gravityview_get_joined_forms( $post->ID ); |
905 | 905 | |
906 | - foreach ( $joined_forms as $form ) { |
|
907 | - $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
908 | - } |
|
906 | + foreach ( $joined_forms as $form ) { |
|
907 | + $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
908 | + } |
|
909 | 909 | } else { |
910 | 910 | $available_items[ $form ] = \GV\Widget::registered(); |
911 | 911 | } |
@@ -935,9 +935,9 @@ discard block |
||
935 | 935 | |
936 | 936 | if ( $form_id ) { |
937 | 937 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
938 | - } else { |
|
938 | + } else { |
|
939 | 939 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
940 | - } |
|
940 | + } |
|
941 | 941 | |
942 | 942 | if ( !$original_item ) { |
943 | 943 | 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 ) ) ); |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | |
991 | 991 | /** |
992 | 992 | * Render the widget active areas |
993 | - * @param string $template_id The current slug of the selected View template |
|
993 | + * @param string $template_id The current slug of the selected View template |
|
994 | 994 | * @param string $zone Either 'header' or 'footer' |
995 | 995 | * @param string $post_id Current Post ID (view) |
996 | 996 | * @return string html |
@@ -1064,13 +1064,13 @@ discard block |
||
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | /** |
1067 | - * Renders "Add Field" tooltips |
|
1068 | - * |
|
1069 | - * @since 2.0.11 |
|
1070 | - * |
|
1067 | + * Renders "Add Field" tooltips |
|
1068 | + * |
|
1069 | + * @since 2.0.11 |
|
1070 | + * |
|
1071 | 1071 | * @param string $context "directory", "single", or "edit" |
1072 | - * |
|
1073 | - * @return void |
|
1072 | + * |
|
1073 | + * @return void |
|
1074 | 1074 | */ |
1075 | 1075 | function render_field_pickers( $context = 'directory' ) { |
1076 | 1076 | |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | </div> |
1098 | 1098 | <?php |
1099 | 1099 | } |
1100 | - } |
|
1100 | + } |
|
1101 | 1101 | |
1102 | 1102 | /** |
1103 | 1103 | * Render the Template Active Areas and configured active fields for a given template id and post id |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | $is_widgets_page = ( $pagenow === 'widgets.php' ); |
1164 | 1164 | |
1165 | 1165 | // Add the GV font (with the Astronaut) |
1166 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1166 | + wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1167 | 1167 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
1168 | 1168 | |
1169 | 1169 | wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
@@ -1171,66 +1171,66 @@ discard block |
||
1171 | 1171 | if( GFForms::get_page() === 'form_list' ) { |
1172 | 1172 | wp_enqueue_style( 'gravityview_views_styles' ); |
1173 | 1173 | return; |
1174 | - } |
|
1174 | + } |
|
1175 | 1175 | |
1176 | 1176 | // Don't process any scripts below here if it's not a GravityView page. |
1177 | 1177 | if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
1178 | - return; |
|
1178 | + return; |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1182 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1183 | - |
|
1184 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1185 | - |
|
1186 | - //enqueue scripts |
|
1187 | - 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' ), \GV\Plugin::$version ); |
|
1188 | - |
|
1189 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1190 | - 'cookiepath' => COOKIEPATH, |
|
1191 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1192 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1193 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1194 | - 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1195 | - 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1196 | - 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1197 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
1198 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1199 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1200 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1201 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1202 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1203 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1204 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1205 | - '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' ), |
|
1206 | - )); |
|
1181 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1182 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1183 | + |
|
1184 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1185 | + |
|
1186 | + //enqueue scripts |
|
1187 | + 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' ), \GV\Plugin::$version ); |
|
1188 | + |
|
1189 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1190 | + 'cookiepath' => COOKIEPATH, |
|
1191 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1192 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1193 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1194 | + 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1195 | + 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1196 | + 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1197 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
1198 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1199 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1200 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1201 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1202 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1203 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1204 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1205 | + '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' ), |
|
1206 | + )); |
|
1207 | 1207 | |
1208 | 1208 | wp_enqueue_style( 'gravityview_views_styles' ); |
1209 | 1209 | |
1210 | - // Enqueue scripts needed for merge tags |
|
1211 | - self::enqueue_gravity_forms_scripts(); |
|
1210 | + // Enqueue scripts needed for merge tags |
|
1211 | + self::enqueue_gravity_forms_scripts(); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
1215 | 1215 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
1216 | - * |
|
1217 | - * @since 1.0.5-beta |
|
1218 | - * |
|
1219 | - * @return void |
|
1216 | + * |
|
1217 | + * @since 1.0.5-beta |
|
1218 | + * |
|
1219 | + * @return void |
|
1220 | 1220 | */ |
1221 | 1221 | static function enqueue_gravity_forms_scripts() { |
1222 | 1222 | GFForms::register_scripts(); |
1223 | 1223 | |
1224 | 1224 | $scripts = array( |
1225 | - 'sack', |
|
1226 | - 'gform_gravityforms', |
|
1227 | - 'gform_forms', |
|
1228 | - 'gform_form_admin', |
|
1229 | - 'jquery-ui-autocomplete' |
|
1225 | + 'sack', |
|
1226 | + 'gform_gravityforms', |
|
1227 | + 'gform_forms', |
|
1228 | + 'gform_form_admin', |
|
1229 | + 'jquery-ui-autocomplete' |
|
1230 | 1230 | ); |
1231 | 1231 | |
1232 | 1232 | if ( wp_is_mobile() ) { |
1233 | - $scripts[] = 'jquery-touch-punch'; |
|
1233 | + $scripts[] = 'jquery-touch-punch'; |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | wp_enqueue_script( $scripts ); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public static function get_duplicate_link( $entry, $view_id, $post_id = null ) { |
248 | 248 | |
249 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
249 | + $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
250 | 250 | |
251 | 251 | if ( empty( $base ) ) { |
252 | 252 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | 'action' => 'duplicate', |
258 | 258 | 'entry_id' => $entry['id'], |
259 | 259 | 'gvid' => $view_id, |
260 | - 'view_id' => $view_id, |
|
260 | + 'view_id' => $view_id, |
|
261 | 261 | ), $base ); |
262 | 262 | |
263 | 263 | return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl ); |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @since 2.5 |
461 | 461 | * @param array $duplicated_entry The duplicated entry |
462 | 462 | * @param array $entry The original entry |
463 | - */ |
|
463 | + */ |
|
464 | 464 | do_action( 'gravityview/duplicate-entry/duplicated', $duplicated_entry, $entry ); |
465 | 465 | |
466 | 466 | gravityview()->log->debug( 'Duplicate response: {duplicate_response}', array( 'duplicate_response' => $duplicate_response ) ); |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | |
32 | 32 | <?php |
33 | 33 | |
34 | - do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID ); |
|
34 | + do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID ); |
|
35 | 35 | |
36 | - do_action('gravityview_render_field_pickers', 'directory' ); |
|
36 | + do_action('gravityview_render_field_pickers', 'directory' ); |
|
37 | 37 | |
38 | - ?> |
|
38 | + ?> |
|
39 | 39 | |
40 | 40 | <?php // list of available widgets to be shown in the popup ?> |
41 | 41 | <div id="directory-available-widgets" class="hide-if-js gv-tooltip"> |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | |
61 | 61 | <div id="single-active-fields" class="gv-grid"> |
62 | 62 | <?php |
63 | - if(!empty( $curr_template ) ) { |
|
64 | - do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true ); |
|
65 | - } |
|
66 | - ?> |
|
63 | + if(!empty( $curr_template ) ) { |
|
64 | + do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true ); |
|
65 | + } |
|
66 | + ?> |
|
67 | 67 | </div> |
68 | 68 | <?php |
69 | - do_action('gravityview_render_field_pickers', 'single' ); |
|
69 | + do_action('gravityview_render_field_pickers', 'single' ); |
|
70 | 70 | ?> |
71 | 71 | </div> |
72 | 72 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | </div> |
86 | 86 | |
87 | 87 | <?php |
88 | - do_action('gravityview_render_field_pickers', 'edit' ); |
|
88 | + do_action('gravityview_render_field_pickers', 'edit' ); |
|
89 | 89 | ?> |
90 | 90 | |
91 | 91 | </div> |
@@ -18,82 +18,82 @@ discard block |
||
18 | 18 | |
19 | 19 | class GravityView_Edit_Entry { |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | 24 | static $file; |
25 | 25 | |
26 | 26 | static $instance; |
27 | 27 | |
28 | - /** |
|
29 | - * Component instances. |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - public $instances = array(); |
|
28 | + /** |
|
29 | + * Component instances. |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + public $instances = array(); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | function __construct() { |
36 | 36 | |
37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
38 | 38 | |
39 | - if( is_admin() ) { |
|
40 | - $this->load_components( 'admin' ); |
|
41 | - } |
|
39 | + if( is_admin() ) { |
|
40 | + $this->load_components( 'admin' ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - $this->load_components( 'render' ); |
|
44 | + $this->load_components( 'render' ); |
|
45 | 45 | |
46 | - // If GF User Registration Add-on exists |
|
47 | - $this->load_components( 'user-registration' ); |
|
46 | + // If GF User Registration Add-on exists |
|
47 | + $this->load_components( 'user-registration' ); |
|
48 | 48 | |
49 | - $this->add_hooks(); |
|
49 | + $this->add_hooks(); |
|
50 | 50 | |
51 | 51 | // Process hooks for addons that may or may not be present |
52 | 52 | $this->addon_specific_hooks(); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - static function getInstance() { |
|
56 | + static function getInstance() { |
|
57 | 57 | |
58 | - if( empty( self::$instance ) ) { |
|
59 | - self::$instance = new GravityView_Edit_Entry; |
|
60 | - } |
|
58 | + if( empty( self::$instance ) ) { |
|
59 | + self::$instance = new GravityView_Edit_Entry; |
|
60 | + } |
|
61 | 61 | |
62 | - return self::$instance; |
|
63 | - } |
|
62 | + return self::$instance; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - private function load_components( $component ) { |
|
66 | + private function load_components( $component ) { |
|
67 | 67 | |
68 | - $dir = trailingslashit( self::$file ); |
|
68 | + $dir = trailingslashit( self::$file ); |
|
69 | 69 | |
70 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
71 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
70 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
71 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
72 | 72 | |
73 | - // Loads component and pass extension's instance so that component can |
|
74 | - // talk each other. |
|
75 | - require_once $filename; |
|
76 | - $this->instances[ $component ] = new $classname( $this ); |
|
77 | - $this->instances[ $component ]->load(); |
|
73 | + // Loads component and pass extension's instance so that component can |
|
74 | + // talk each other. |
|
75 | + require_once $filename; |
|
76 | + $this->instances[ $component ] = new $classname( $this ); |
|
77 | + $this->instances[ $component ]->load(); |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - private function add_hooks() { |
|
81 | + private function add_hooks() { |
|
82 | 82 | |
83 | - // Add front-end access to Gravity Forms delete file action |
|
84 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
83 | + // Add front-end access to Gravity Forms delete file action |
|
84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
85 | 85 | |
86 | - // Make sure this hook is run for non-admins |
|
87 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
86 | + // Make sure this hook is run for non-admins |
|
87 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
88 | 88 | |
89 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
89 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
90 | 90 | |
91 | - // add template path to check for field |
|
92 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
91 | + // add template path to check for field |
|
92 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
93 | 93 | |
94 | 94 | add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 ); |
95 | 95 | |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin |
@@ -151,74 +151,74 @@ discard block |
||
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * Include this extension templates path |
|
156 | - * @param array $file_paths List of template paths ordered |
|
157 | - */ |
|
158 | - public function add_template_path( $file_paths ) { |
|
159 | - |
|
160 | - // Index 100 is the default GravityView template path. |
|
161 | - $file_paths[ 110 ] = self::$file; |
|
162 | - |
|
163 | - return $file_paths; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * |
|
168 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
169 | - * |
|
170 | - * @param $view_id int GravityView view id |
|
171 | - * @param $form_id int Gravity Forms form id |
|
172 | - * @param $entry_id int Gravity Forms entry id |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
176 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * The edit entry link creates a secure link with a nonce |
|
182 | - * |
|
183 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
184 | - * it formats the display of the edit form like it does in the backend, like |
|
185 | - * "You can edit this post from the post page" fields, for example. |
|
186 | - * |
|
187 | - * @param $entry array Gravity Forms entry object |
|
188 | - * @param $view_id int GravityView view id |
|
189 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
190 | - * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
194 | - |
|
195 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
196 | - |
|
197 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
198 | - |
|
199 | - $url = add_query_arg( array( |
|
200 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
201 | - ), $base ); |
|
202 | - |
|
203 | - if( $post_id ) { |
|
204 | - $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Allow passing params to dynamically populate entry with values |
|
209 | - * @since 1.9.2 |
|
210 | - */ |
|
211 | - if( !empty( $field_values ) ) { |
|
212 | - |
|
213 | - if( is_array( $field_values ) ) { |
|
214 | - // If already an array, no parse_str() needed |
|
215 | - $params = $field_values; |
|
216 | - } else { |
|
217 | - parse_str( $field_values, $params ); |
|
218 | - } |
|
219 | - |
|
220 | - $url = add_query_arg( $params, $url ); |
|
221 | - } |
|
154 | + /** |
|
155 | + * Include this extension templates path |
|
156 | + * @param array $file_paths List of template paths ordered |
|
157 | + */ |
|
158 | + public function add_template_path( $file_paths ) { |
|
159 | + |
|
160 | + // Index 100 is the default GravityView template path. |
|
161 | + $file_paths[ 110 ] = self::$file; |
|
162 | + |
|
163 | + return $file_paths; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * |
|
168 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
169 | + * |
|
170 | + * @param $view_id int GravityView view id |
|
171 | + * @param $form_id int Gravity Forms form id |
|
172 | + * @param $entry_id int Gravity Forms entry id |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
176 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * The edit entry link creates a secure link with a nonce |
|
182 | + * |
|
183 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
184 | + * it formats the display of the edit form like it does in the backend, like |
|
185 | + * "You can edit this post from the post page" fields, for example. |
|
186 | + * |
|
187 | + * @param $entry array Gravity Forms entry object |
|
188 | + * @param $view_id int GravityView view id |
|
189 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
190 | + * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
194 | + |
|
195 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
196 | + |
|
197 | + $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
198 | + |
|
199 | + $url = add_query_arg( array( |
|
200 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
201 | + ), $base ); |
|
202 | + |
|
203 | + if( $post_id ) { |
|
204 | + $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Allow passing params to dynamically populate entry with values |
|
209 | + * @since 1.9.2 |
|
210 | + */ |
|
211 | + if( !empty( $field_values ) ) { |
|
212 | + |
|
213 | + if( is_array( $field_values ) ) { |
|
214 | + // If already an array, no parse_str() needed |
|
215 | + $params = $field_values; |
|
216 | + } else { |
|
217 | + parse_str( $field_values, $params ); |
|
218 | + } |
|
219 | + |
|
220 | + $url = add_query_arg( $params, $url ); |
|
221 | + } |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * @filter `gravityview/edit/link` Filter the edit URL link. |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param \GV\View $view The View. |
228 | 228 | */ |
229 | 229 | return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Edit mode doesn't allow certain field types. |
@@ -282,19 +282,19 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | |
285 | - /** |
|
286 | - * checks if user has permissions to edit a specific entry |
|
287 | - * |
|
288 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
289 | - * |
|
290 | - * @param array $entry Gravity Forms entry array |
|
291 | - * @param \GV\View int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
292 | - * @return bool |
|
293 | - */ |
|
294 | - public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
285 | + /** |
|
286 | + * checks if user has permissions to edit a specific entry |
|
287 | + * |
|
288 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
289 | + * |
|
290 | + * @param array $entry Gravity Forms entry array |
|
291 | + * @param \GV\View int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
292 | + * @return bool |
|
293 | + */ |
|
294 | + public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
295 | 295 | |
296 | - // No permission by default |
|
297 | - $user_can_edit = false; |
|
296 | + // No permission by default |
|
297 | + $user_can_edit = false; |
|
298 | 298 | |
299 | 299 | // get user_edit setting |
300 | 300 | if ( empty( $view ) ) { |
@@ -312,59 +312,59 @@ discard block |
||
312 | 312 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
313 | 313 | } |
314 | 314 | |
315 | - // If they can edit any entries (as defined in Gravity Forms) |
|
316 | - // Or if they can edit other people's entries |
|
317 | - // Then we're good. |
|
318 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
315 | + // If they can edit any entries (as defined in Gravity Forms) |
|
316 | + // Or if they can edit other people's entries |
|
317 | + // Then we're good. |
|
318 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
319 | 319 | |
320 | - gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
320 | + gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
321 | 321 | |
322 | - $user_can_edit = true; |
|
322 | + $user_can_edit = true; |
|
323 | 323 | |
324 | - } else if( !isset( $entry['created_by'] ) ) { |
|
324 | + } else if( !isset( $entry['created_by'] ) ) { |
|
325 | 325 | |
326 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
326 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
327 | 327 | |
328 | - $user_can_edit = false; |
|
328 | + $user_can_edit = false; |
|
329 | 329 | |
330 | - } else { |
|
330 | + } else { |
|
331 | 331 | |
332 | 332 | |
333 | - $current_user = wp_get_current_user(); |
|
333 | + $current_user = wp_get_current_user(); |
|
334 | 334 | |
335 | - // User edit is disabled |
|
336 | - if( empty( $user_edit ) ) { |
|
335 | + // User edit is disabled |
|
336 | + if( empty( $user_edit ) ) { |
|
337 | 337 | |
338 | - gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
338 | + gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
339 | 339 | |
340 | - $user_can_edit = false; |
|
341 | - } |
|
340 | + $user_can_edit = false; |
|
341 | + } |
|
342 | 342 | |
343 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
344 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
343 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
344 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
345 | 345 | |
346 | - gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
346 | + gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
347 | 347 | |
348 | - $user_can_edit = true; |
|
348 | + $user_can_edit = true; |
|
349 | 349 | |
350 | - } else if( ! is_user_logged_in() ) { |
|
350 | + } else if( ! is_user_logged_in() ) { |
|
351 | 351 | |
352 | - gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
353 | - } |
|
352 | + gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
353 | + } |
|
354 | 354 | |
355 | - } |
|
355 | + } |
|
356 | 356 | |
357 | - /** |
|
358 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
359 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
360 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
361 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
362 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
363 | - */ |
|
364 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
357 | + /** |
|
358 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
359 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
360 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
361 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
362 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
363 | + */ |
|
364 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
365 | 365 | |
366 | - return (bool)$user_can_edit; |
|
367 | - } |
|
366 | + return (bool)$user_can_edit; |
|
367 | + } |
|
368 | 368 | |
369 | 369 | |
370 | 370 |