@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
248 | - * @hack |
|
249 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
250 | - */ |
|
248 | + * @hack |
|
249 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
250 | + */ |
|
251 | 251 | if( 'email' === $field->type && false === strpos( $input['id'], '.' ) ) { |
252 | - continue; |
|
253 | - } |
|
252 | + continue; |
|
253 | + } |
|
254 | 254 | $fields["{$input['id']}"] = array( |
255 | 255 | 'label' => rgar( $input, 'label' ), |
256 | 256 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
428 | 428 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
429 | 429 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
430 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
430 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
431 | 431 | $criteria['context_view_id'] = null; |
432 | 432 | } |
433 | 433 | |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | ), |
1163 | 1163 | ); |
1164 | 1164 | |
1165 | - $fields = $date_created + $fields; |
|
1165 | + $fields = $date_created + $fields; |
|
1166 | 1166 | |
1167 | 1167 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1168 | 1168 | |
@@ -1174,13 +1174,13 @@ discard block |
||
1174 | 1174 | } |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - /** |
|
1178 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1179 | - * @since 1.12 |
|
1180 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1181 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1182 | - */ |
|
1183 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1177 | + /** |
|
1178 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1179 | + * @since 1.12 |
|
1180 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1181 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1182 | + */ |
|
1183 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1184 | 1184 | |
1185 | 1185 | return $fields; |
1186 | 1186 | } |
@@ -1472,17 +1472,17 @@ discard block |
||
1472 | 1472 | } |
1473 | 1473 | |
1474 | 1474 | |
1475 | - /** |
|
1476 | - * Display updated/error notice |
|
1477 | - * |
|
1478 | - * @param string $notice text/HTML of notice |
|
1479 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1480 | - * |
|
1481 | - * @return string |
|
1482 | - */ |
|
1483 | - public static function generate_notice( $notice, $class = '' ) { |
|
1484 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1485 | - } |
|
1475 | + /** |
|
1476 | + * Display updated/error notice |
|
1477 | + * |
|
1478 | + * @param string $notice text/HTML of notice |
|
1479 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1480 | + * |
|
1481 | + * @return string |
|
1482 | + */ |
|
1483 | + public static function generate_notice( $notice, $class = '' ) { |
|
1484 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1485 | + } |
|
1486 | 1486 | |
1487 | 1487 | /** |
1488 | 1488 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * |
222 | 222 | * If the user doesn't have the `gravityview_support_port` capability, returns false; then |
223 | 223 | * If global setting is "hide", returns false; then |
224 | - * If user preference is not set, return global setting; then |
|
225 | - * If user preference is set, return that setting. |
|
224 | + * If user preference is not set, return global setting; then |
|
225 | + * If user preference is set, return that setting. |
|
226 | 226 | * |
227 | 227 | * @since 1.15 |
228 | - * @since 1.17.5 Changed behavior to respect global setting |
|
228 | + * @since 1.17.5 Changed behavior to respect global setting |
|
229 | 229 | * |
230 | 230 | * @param int $user Optional. ID of the user to check, defaults to 0 for current user. |
231 | 231 | * |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $global_setting = GravityView_Settings::getSetting( 'support_port' ); |
241 | 241 | |
242 | 242 | if ( empty( $global_setting ) ) { |
243 | - return false; |
|
243 | + return false; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Get the per-user Support Port setting |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * Modifies the output of profile.php to add GravityView Support preference |
277 | 277 | * |
278 | 278 | * @since 1.15 |
279 | - * @since 1.17.5 Only show if global setting is active |
|
279 | + * @since 1.17.5 Only show if global setting is active |
|
280 | 280 | * |
281 | 281 | * @param WP_User $user Current user info |
282 | 282 | * |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $global_setting = GravityView_Settings::getSetting( 'support_port' ); |
288 | 288 | |
289 | 289 | if ( empty( $global_setting ) ) { |
290 | - return; |
|
290 | + return; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | if( empty( $connected_views ) ) { |
138 | 138 | |
139 | - $menu_items['gravityview'] = array( |
|
139 | + $menu_items['gravityview'] = array( |
|
140 | 140 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
141 | 141 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
142 | 142 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | // If there were no items added, then let's create the parent menu |
168 | 168 | if( $sub_menu_items ) { |
169 | 169 | |
170 | - $sub_menu_items[] = array( |
|
171 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
172 | - 'link_class' => 'gv-create-view', |
|
173 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
174 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
175 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
176 | - ); |
|
170 | + $sub_menu_items[] = array( |
|
171 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
172 | + 'link_class' => 'gv-create-view', |
|
173 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
174 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
175 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
176 | + ); |
|
177 | 177 | |
178 | 178 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
179 | 179 | $sub_menu_items[] = array( |
@@ -549,12 +549,12 @@ discard block |
||
549 | 549 | * Render html for displaying available fields based on a Form ID |
550 | 550 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
551 | 551 | * |
552 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
552 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
553 | 553 | * @access public |
554 | - * |
|
554 | + * |
|
555 | 555 | * @param int $form Gravity Forms Form ID (default: '') |
556 | 556 | * @param string $context (default: 'single') |
557 | - * |
|
557 | + * |
|
558 | 558 | * @return void |
559 | 559 | */ |
560 | 560 | function render_available_fields( $form = 0, $context = 'single' ) { |
@@ -702,12 +702,12 @@ discard block |
||
702 | 702 | /** |
703 | 703 | * @since 1.7.2 |
704 | 704 | */ |
705 | - 'other_entries' => array( |
|
706 | - 'label' => __('Other Entries', 'gravityview'), |
|
707 | - 'type' => 'other_entries', |
|
708 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
709 | - ), |
|
710 | - ); |
|
705 | + 'other_entries' => array( |
|
706 | + 'label' => __('Other Entries', 'gravityview'), |
|
707 | + 'type' => 'other_entries', |
|
708 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
709 | + ), |
|
710 | + ); |
|
711 | 711 | |
712 | 712 | if( 'single' !== $zone) { |
713 | 713 | |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | |
1025 | 1025 | wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
1026 | 1026 | 'cookiepath' => COOKIEPATH, |
1027 | - 'passed_form_id' => (bool) rgget( 'form_id' ), |
|
1027 | + 'passed_form_id' => (bool) rgget( 'form_id' ), |
|
1028 | 1028 | 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
1029 | 1029 | 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
1030 | 1030 | 'label_close' => __( 'Close', 'gravityview' ), |
@@ -1049,15 +1049,15 @@ discard block |
||
1049 | 1049 | GFForms::register_scripts(); |
1050 | 1050 | |
1051 | 1051 | $scripts = array( |
1052 | - 'sack', |
|
1053 | - 'gform_gravityforms', |
|
1054 | - 'gform_forms', |
|
1055 | - 'gform_form_admin', |
|
1056 | - 'jquery-ui-autocomplete' |
|
1052 | + 'sack', |
|
1053 | + 'gform_gravityforms', |
|
1054 | + 'gform_forms', |
|
1055 | + 'gform_form_admin', |
|
1056 | + 'jquery-ui-autocomplete' |
|
1057 | 1057 | ); |
1058 | 1058 | |
1059 | 1059 | if ( wp_is_mobile() ) { |
1060 | - $scripts[] = 'jquery-touch-punch'; |
|
1060 | + $scripts[] = 'jquery-touch-punch'; |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | foreach ($scripts as $script) { |
@@ -346,14 +346,14 @@ discard block |
||
346 | 346 | /** |
347 | 347 | * update_approved function. |
348 | 348 | * |
349 | - * @since 1.18 Moved to GravityView_Entry_Approval::update_approved |
|
349 | + * @since 1.18 Moved to GravityView_Entry_Approval::update_approved |
|
350 | 350 | * @see GravityView_Entry_Approval::update_approved |
351 | - * |
|
351 | + * |
|
352 | 352 | * @param int $entry_id (default: 0) |
353 | 353 | * @param int $approved (default: 0) |
354 | 354 | * @param int $form_id (default: 0) |
355 | 355 | * @param int $approvedcolumn (default: 0) |
356 | - * |
|
356 | + * |
|
357 | 357 | * @return boolean True: It worked; False: it failed |
358 | 358 | */ |
359 | 359 | public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | /** |
364 | 364 | * Calculate the approve field.input id |
365 | 365 | * |
366 | - * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column |
|
367 | - * @see GravityView_Entry_Approval::get_approved_column |
|
368 | - * |
|
366 | + * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column |
|
367 | + * @see GravityView_Entry_Approval::get_approved_column |
|
368 | + * |
|
369 | 369 | * @param mixed $form GF Form or Form ID |
370 | 370 | * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
371 | 371 | */ |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | 'bulk_actions' => $this->get_bulk_actions( $form_id ), |
488 | 488 | 'bulk_message' => $this->bulk_update_message, |
489 | 489 | 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'), |
490 | - 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
490 | + 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
491 | 491 | 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'), |
492 | 492 | 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
493 | 493 | 'column_link' => esc_url( $this->get_sort_link( $form_id ) ), |
@@ -496,11 +496,11 @@ discard block |
||
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
499 | - * Generate a link to sort by approval status (if there is an Approve/Disapprove field) |
|
500 | - * |
|
501 | - * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as |
|
502 | - * numeric, but it does group the approved entries together. |
|
503 | - * |
|
499 | + * Generate a link to sort by approval status (if there is an Approve/Disapprove field) |
|
500 | + * |
|
501 | + * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as |
|
502 | + * numeric, but it does group the approved entries together. |
|
503 | + * |
|
504 | 504 | * @param int $form_id |
505 | 505 | * |
506 | 506 | * @return string Sorting link |
@@ -510,20 +510,20 @@ discard block |
||
510 | 510 | $approved_column_id = self::get_approved_column( $form_id ); |
511 | 511 | |
512 | 512 | if( ! $approved_column_id ) { |
513 | - return ''; |
|
514 | - } |
|
513 | + return ''; |
|
514 | + } |
|
515 | 515 | |
516 | - $order = ( 'desc' === rgget('order') ) ? 'asc' : 'desc'; |
|
516 | + $order = ( 'desc' === rgget('order') ) ? 'asc' : 'desc'; |
|
517 | 517 | |
518 | - $args = array( |
|
519 | - 'orderby' => $approved_column_id, |
|
520 | - 'order' => $order, |
|
521 | - ); |
|
518 | + $args = array( |
|
519 | + 'orderby' => $approved_column_id, |
|
520 | + 'order' => $order, |
|
521 | + ); |
|
522 | 522 | |
523 | - $link = add_query_arg( $args ); |
|
523 | + $link = add_query_arg( $args ); |
|
524 | 524 | |
525 | 525 | return $link; |
526 | - } |
|
526 | + } |
|
527 | 527 | |
528 | 528 | /** |
529 | 529 | * Get an array of options to be added to the Gravity Forms "Bulk action" dropdown in a "GravityView" option group |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * Verify permissions. Check expected $_POST. Parse args, then send to process_delete_notes |
270 | 270 | * |
271 | - * @since 1.17 |
|
271 | + * @since 1.17 |
|
272 | 272 | * |
273 | 273 | * @see process_delete_notes |
274 | 274 | * |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | 'subject-label' => __( 'Subject', 'gravityview' ), |
422 | 422 | 'subject' => __( 'Email subject', 'gravityview' ), |
423 | 423 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
424 | - 'email-footer' => __( 'This note was sent from {url}', 'gravityview' ), |
|
424 | + 'email-footer' => __( 'This note was sent from {url}', 'gravityview' ), |
|
425 | 425 | 'also-email' => __( 'Also email this note to', 'gravityview' ), |
426 | 426 | 'error-add-note' => __( 'There was an error adding the note.', 'gravityview' ), |
427 | 427 | 'error-invalid' => __( 'The request was invalid. Refresh the page and try again.', 'gravityview' ), |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | 'gv-note-to-custom' => '', |
711 | 711 | 'gv-note-subject' => '', |
712 | 712 | 'gv-note-content' => '', |
713 | - 'current-url' => '', |
|
713 | + 'current-url' => '', |
|
714 | 714 | ); |
715 | 715 | |
716 | 716 | $current_user = wp_get_current_user(); |
@@ -762,9 +762,9 @@ discard block |
||
762 | 762 | $message .= $this->get_email_footer( $email_footer, $is_html, $email_data ); |
763 | 763 | |
764 | 764 | /** |
765 | - * @filter `gravityview/field/notes/wpautop_email` Should the message content have paragraphs added automatically, if using HTML message format |
|
765 | + * @filter `gravityview/field/notes/wpautop_email` Should the message content have paragraphs added automatically, if using HTML message format |
|
766 | 766 | * @since 1.18 |
767 | - * @param bool $wpautop_email True: Apply wpautop() to the email message if using; False: Leave as entered (Default: true) |
|
767 | + * @param bool $wpautop_email True: Apply wpautop() to the email message if using; False: Leave as entered (Default: true) |
|
768 | 768 | */ |
769 | 769 | $wpautop_email = apply_filters( 'gravityview/field/notes/wpautop_email', true ); |
770 | 770 | |
@@ -784,12 +784,12 @@ discard block |
||
784 | 784 | } |
785 | 785 | |
786 | 786 | /** |
787 | - * Get the footer for Entry Note emails |
|
788 | - * |
|
789 | - * `{url}` is replaced by the URL of the page where the note form was embedded |
|
790 | - * |
|
791 | - * @since 1.18 |
|
792 | - * @see GravityView_Field_Notes::strings The default value of $message_footer is set here, with the key 'email-footer' |
|
787 | + * Get the footer for Entry Note emails |
|
788 | + * |
|
789 | + * `{url}` is replaced by the URL of the page where the note form was embedded |
|
790 | + * |
|
791 | + * @since 1.18 |
|
792 | + * @see GravityView_Field_Notes::strings The default value of $message_footer is set here, with the key 'email-footer' |
|
793 | 793 | * |
794 | 794 | * @param string $email_footer The message footer value |
795 | 795 | * @param bool $is_html True: Email is being sent as HTML; False: sent as text |
@@ -798,10 +798,10 @@ discard block |
||
798 | 798 | */ |
799 | 799 | private function get_email_footer( $email_footer = '', $is_html = true, $email_data = array() ) { |
800 | 800 | |
801 | - $output = ''; |
|
801 | + $output = ''; |
|
802 | 802 | |
803 | 803 | if( ! empty( $email_footer ) ) { |
804 | - $url = rgar( $email_data, 'current-url' ); |
|
804 | + $url = rgar( $email_data, 'current-url' ); |
|
805 | 805 | $url = html_entity_decode( $url ); |
806 | 806 | $url = site_url( $url ); |
807 | 807 |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function getPaging() { |
421 | 421 | |
422 | - $default_params = array( |
|
423 | - 'offset' => 0, |
|
424 | - 'page_size' => 20, |
|
425 | - ); |
|
422 | + $default_params = array( |
|
423 | + 'offset' => 0, |
|
424 | + 'page_size' => 20, |
|
425 | + ); |
|
426 | 426 | |
427 | 427 | return wp_parse_args( $this->paging, $default_params ); |
428 | 428 | } |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | public function getSorting() { |
480 | 480 | |
481 | 481 | $defaults_params = array( |
482 | - 'sort_field' => 'date_created', |
|
483 | - 'sort_direction' => 'ASC', |
|
484 | - 'is_numeric' => false, |
|
485 | - ); |
|
482 | + 'sort_field' => 'date_created', |
|
483 | + 'sort_direction' => 'ASC', |
|
484 | + 'is_numeric' => false, |
|
485 | + ); |
|
486 | 486 | |
487 | 487 | return wp_parse_args( $this->sorting, $defaults_params ); |
488 | 488 | } |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | - * Uninstall all traces of GravityView |
|
126 | - * |
|
127 | - * Note: method is public because parent method is public |
|
128 | - * |
|
125 | + * Uninstall all traces of GravityView |
|
126 | + * |
|
127 | + * Note: method is public because parent method is public |
|
128 | + * |
|
129 | 129 | * @return bool |
130 | 130 | */ |
131 | 131 | public function uninstall() { |
@@ -137,53 +137,53 @@ discard block |
||
137 | 137 | $uninstaller->fire_everything(); |
138 | 138 | |
139 | 139 | /** |
140 | - * Set the path so that Gravity Forms can de-activate GravityView |
|
141 | - * @see GFAddOn::uninstall_addon |
|
142 | - * @uses deactivate_plugins() |
|
143 | - */ |
|
140 | + * Set the path so that Gravity Forms can de-activate GravityView |
|
141 | + * @see GFAddOn::uninstall_addon |
|
142 | + * @uses deactivate_plugins() |
|
143 | + */ |
|
144 | 144 | $this->_path = GRAVITYVIEW_FILE; |
145 | 145 | |
146 | 146 | return true; |
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
150 | - * Get an array of reasons why the plugin might be uninstalled |
|
151 | - * |
|
152 | - * @since 1.17.5 |
|
153 | - * |
|
150 | + * Get an array of reasons why the plugin might be uninstalled |
|
151 | + * |
|
152 | + * @since 1.17.5 |
|
153 | + * |
|
154 | 154 | * @return array Array of reasons with the label and followup questions for each uninstall reason |
155 | 155 | */ |
156 | 156 | private function get_uninstall_reasons() { |
157 | 157 | |
158 | 158 | $reasons = array( |
159 | 159 | 'will-continue' => array( |
160 | - 'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ), |
|
161 | - ), |
|
160 | + 'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ), |
|
161 | + ), |
|
162 | 162 | 'no-longer-need' => array( |
163 | - 'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ), |
|
164 | - ), |
|
163 | + 'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ), |
|
164 | + ), |
|
165 | 165 | 'doesnt-work' => array( |
166 | - 'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ), |
|
167 | - ), |
|
166 | + 'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ), |
|
167 | + ), |
|
168 | 168 | 'found-other' => array( |
169 | - 'label' => esc_html__( 'I found a better plugin', 'gravityview' ), |
|
170 | - 'followup' => esc_attr__('What plugin you are using, and why?', 'gravityview'), |
|
171 | - ), |
|
169 | + 'label' => esc_html__( 'I found a better plugin', 'gravityview' ), |
|
170 | + 'followup' => esc_attr__('What plugin you are using, and why?', 'gravityview'), |
|
171 | + ), |
|
172 | 172 | 'other' => array( |
173 | - 'label' => esc_html__( 'Other', 'gravityview' ), |
|
174 | - ), |
|
173 | + 'label' => esc_html__( 'Other', 'gravityview' ), |
|
174 | + ), |
|
175 | 175 | ); |
176 | 176 | |
177 | 177 | shuffle( $reasons ); |
178 | 178 | |
179 | 179 | return $reasons; |
180 | - } |
|
180 | + } |
|
181 | 181 | |
182 | 182 | /** |
183 | - * Display a feedback form when the plugin is uninstalled |
|
184 | - * |
|
185 | - * @since 1.17.5 |
|
186 | - * |
|
183 | + * Display a feedback form when the plugin is uninstalled |
|
184 | + * |
|
185 | + * @since 1.17.5 |
|
186 | + * |
|
187 | 187 | * @return string HTML of the uninstallation form |
188 | 188 | */ |
189 | 189 | public function uninstall_form() { |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | <h2><?php esc_html_e( 'Why did you uninstall GravityView?', 'gravityview' ); ?></h2> |
264 | 264 | <ul> |
265 | 265 | <?php |
266 | - $reasons = $this->get_uninstall_reasons(); |
|
266 | + $reasons = $this->get_uninstall_reasons(); |
|
267 | 267 | foreach ( $reasons as $reason ) { |
268 | 268 | printf( '<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', rgar( $reason, 'followup' ), rgar( $reason, 'label' ) ); |
269 | 269 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | $license_key = self::getSetting('license_key'); |
432 | 432 | if( '' === $license_key ) { |
433 | 433 | $license_status = 'inactive'; |
434 | - } |
|
434 | + } |
|
435 | 435 | $license_id = empty( $license_key ) ? 'license' : $license_key; |
436 | 436 | |
437 | 437 | $message = esc_html__('Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview'); |
@@ -569,12 +569,12 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | public function app_settings_tab() { |
572 | - parent::app_settings_tab(); |
|
572 | + parent::app_settings_tab(); |
|
573 | 573 | |
574 | 574 | if ( $this->maybe_uninstall() ) { |
575 | - echo $this->uninstall_form(); |
|
575 | + echo $this->uninstall_form(); |
|
576 | 576 | } |
577 | - } |
|
577 | + } |
|
578 | 578 | |
579 | 579 | /** |
580 | 580 | * Make protected public |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | type="' . $field['type'] . '" |
698 | 698 | name="' . esc_attr( $name ) . '" |
699 | 699 | value="' . $value . '" ' . |
700 | - implode( ' ', $attributes ) . |
|
701 | - ' />'; |
|
700 | + implode( ' ', $attributes ) . |
|
701 | + ' />'; |
|
702 | 702 | |
703 | 703 | if ( $echo ) { |
704 | 704 | echo $html; |
@@ -933,36 +933,36 @@ discard block |
||
933 | 933 | } |
934 | 934 | |
935 | 935 | |
936 | - $sections = array( |
|
937 | - array( |
|
938 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
939 | - 'fields' => $fields, |
|
940 | - ) |
|
941 | - ); |
|
936 | + $sections = array( |
|
937 | + array( |
|
938 | + 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
939 | + 'fields' => $fields, |
|
940 | + ) |
|
941 | + ); |
|
942 | 942 | |
943 | - // custom 'update settings' button |
|
944 | - $button = array( |
|
945 | - 'class' => 'button button-primary button-hero', |
|
946 | - 'type' => 'save', |
|
947 | - ); |
|
943 | + // custom 'update settings' button |
|
944 | + $button = array( |
|
945 | + 'class' => 'button button-primary button-hero', |
|
946 | + 'type' => 'save', |
|
947 | + ); |
|
948 | 948 | |
949 | 949 | if( $disabled_attribute ) { |
950 | 950 | $button['disabled'] = $disabled_attribute; |
951 | 951 | } |
952 | 952 | |
953 | 953 | |
954 | - /** |
|
955 | - * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
956 | - * Extensions can tap in here to insert their own section and settings. |
|
957 | - * <code> |
|
958 | - * $sections[] = array( |
|
959 | - * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
960 | - * 'fields' => $settings, |
|
961 | - * ); |
|
962 | - * </code> |
|
963 | - * @param array $extension_settings Empty array, ready for extension settings! |
|
964 | - */ |
|
965 | - $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
954 | + /** |
|
955 | + * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
956 | + * Extensions can tap in here to insert their own section and settings. |
|
957 | + * <code> |
|
958 | + * $sections[] = array( |
|
959 | + * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
960 | + * 'fields' => $settings, |
|
961 | + * ); |
|
962 | + * </code> |
|
963 | + * @param array $extension_settings Empty array, ready for extension settings! |
|
964 | + */ |
|
965 | + $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
966 | 966 | |
967 | 967 | // If there are extensions, add a section for them |
968 | 968 | if ( ! empty( $extension_sections ) ) { |
@@ -975,13 +975,13 @@ discard block |
||
975 | 975 | } |
976 | 976 | } |
977 | 977 | |
978 | - $k = count( $extension_sections ) - 1 ; |
|
979 | - $extension_sections[ $k ]['fields'][] = $button; |
|
978 | + $k = count( $extension_sections ) - 1 ; |
|
979 | + $extension_sections[ $k ]['fields'][] = $button; |
|
980 | 980 | $sections = array_merge( $sections, $extension_sections ); |
981 | 981 | } else { |
982 | - // add the 'update settings' button to the general section |
|
983 | - $sections[0]['fields'][] = $button; |
|
984 | - } |
|
982 | + // add the 'update settings' button to the general section |
|
983 | + $sections[0]['fields'][] = $button; |
|
984 | + } |
|
985 | 985 | |
986 | 986 | return $sections; |
987 | 987 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | if ( ! defined( 'WPINC' ) ) { |
14 | - die; |
|
14 | + die; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -22,253 +22,253 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @var GravityView_Edit_Entry |
24 | 24 | */ |
25 | - protected $loader; |
|
25 | + protected $loader; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var WP_User|null Temporary storage used by restore_user_details() |
|
29 | - */ |
|
30 | - private $_user_before_update = null; |
|
27 | + /** |
|
28 | + * @var WP_User|null Temporary storage used by restore_user_details() |
|
29 | + */ |
|
30 | + private $_user_before_update = null; |
|
31 | 31 | |
32 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
33 | - $this->loader = $loader; |
|
34 | - } |
|
32 | + function __construct( GravityView_Edit_Entry $loader ) { |
|
33 | + $this->loader = $loader; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @since 1.11 |
38 | 38 | */ |
39 | 39 | public function load() { |
40 | 40 | add_action( 'wp', array( $this, 'add_hooks' ), 10 ); |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Add hooks to trigger updating the user |
45 | 45 | * |
46 | 46 | * @since 1.18 |
47 | 47 | */ |
48 | - public function add_hooks() { |
|
49 | - |
|
50 | - /** |
|
51 | - * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
52 | - * @since 1.11 |
|
53 | - * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
54 | - */ |
|
55 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | - |
|
57 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
58 | - |
|
59 | - // last resort in case the current user display name don't match any of the defaults |
|
60 | - add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Update the WordPress user profile based on the GF User Registration create feed |
|
66 | - * |
|
67 | - * @since 1.11 |
|
68 | - * |
|
69 | - * @param array $form Gravity Forms form array |
|
70 | - * @param string $entry_id Gravity Forms entry ID |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - public function update_user( $form = array(), $entry_id = 0 ) { |
|
74 | - |
|
75 | - if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) { |
|
76 | - return; |
|
77 | - } |
|
78 | - |
|
79 | - /** @var GF_User_Registration $gf_user_registration */ |
|
80 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
81 | - |
|
82 | - $entry = GFAPI::get_entry( $entry_id ); |
|
83 | - |
|
84 | - /** |
|
85 | - * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
86 | - * @since 1.11 |
|
87 | - * @param array $entry Gravity Forms entry |
|
88 | - * @param array $form Gravity Forms form |
|
89 | - */ |
|
90 | - $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
91 | - |
|
92 | - $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
93 | - |
|
94 | - /** |
|
95 | - * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
96 | - * @since 1.15 |
|
97 | - * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
98 | - * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
99 | - * @param[in] array $form Gravity Forms form array |
|
100 | - * @param[in] array $entry Gravity Forms entry being edited |
|
101 | - */ |
|
102 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
103 | - |
|
104 | - if( $preserve_role ) { |
|
105 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Make sure the current display name is not changed with the update user method. |
|
110 | - * @since 1.15 |
|
111 | - */ |
|
112 | - $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
117 | - * @since 1.14 |
|
118 | - * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
119 | - * @param[in] array $form Gravity Forms form array |
|
120 | - * @param[in] array $entry Gravity Forms entry being edited |
|
121 | - */ |
|
122 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
123 | - |
|
124 | - |
|
125 | - // Make sure the feed is active |
|
126 | - if ( ! rgar( $config, 'is_active', false ) ) { |
|
48 | + public function add_hooks() { |
|
49 | + |
|
50 | + /** |
|
51 | + * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
52 | + * @since 1.11 |
|
53 | + * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
54 | + */ |
|
55 | + if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | + |
|
57 | + add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
58 | + |
|
59 | + // last resort in case the current user display name don't match any of the defaults |
|
60 | + add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Update the WordPress user profile based on the GF User Registration create feed |
|
66 | + * |
|
67 | + * @since 1.11 |
|
68 | + * |
|
69 | + * @param array $form Gravity Forms form array |
|
70 | + * @param string $entry_id Gravity Forms entry ID |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + public function update_user( $form = array(), $entry_id = 0 ) { |
|
74 | + |
|
75 | + if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) { |
|
76 | + return; |
|
77 | + } |
|
78 | + |
|
79 | + /** @var GF_User_Registration $gf_user_registration */ |
|
80 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
81 | + |
|
82 | + $entry = GFAPI::get_entry( $entry_id ); |
|
83 | + |
|
84 | + /** |
|
85 | + * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
86 | + * @since 1.11 |
|
87 | + * @param array $entry Gravity Forms entry |
|
88 | + * @param array $form Gravity Forms form |
|
89 | + */ |
|
90 | + $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
91 | + |
|
92 | + $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
93 | + |
|
94 | + /** |
|
95 | + * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
96 | + * @since 1.15 |
|
97 | + * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
98 | + * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
99 | + * @param[in] array $form Gravity Forms form array |
|
100 | + * @param[in] array $entry Gravity Forms entry being edited |
|
101 | + */ |
|
102 | + $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
103 | + |
|
104 | + if( $preserve_role ) { |
|
105 | + $config['meta']['role'] = 'gfur_preserve_role'; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Make sure the current display name is not changed with the update user method. |
|
110 | + * @since 1.15 |
|
111 | + */ |
|
112 | + $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
117 | + * @since 1.14 |
|
118 | + * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
119 | + * @param[in] array $form Gravity Forms form array |
|
120 | + * @param[in] array $entry Gravity Forms entry being edited |
|
121 | + */ |
|
122 | + $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
123 | + |
|
124 | + |
|
125 | + // Make sure the feed is active |
|
126 | + if ( ! rgar( $config, 'is_active', false ) ) { |
|
127 | 127 | return; |
128 | - } |
|
129 | - |
|
130 | - // If an Update feed, make sure the conditions are met. |
|
131 | - if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
132 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
133 | - return; |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - // The priority is set to 3 so that default priority (10) will still override it |
|
138 | - add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
139 | - add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
140 | - |
|
141 | - // Trigger the User Registration update user method |
|
142 | - $gf_user_registration->update_user( $entry, $form, $config ); |
|
143 | - |
|
144 | - remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
145 | - remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
146 | - |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * Calculate the user display name format |
|
151 | - * |
|
152 | - * @since 1.15 |
|
153 | - * |
|
154 | - * @param int $user_id WP User ID |
|
155 | - * @return string Display name format as used inside Gravity Forms User Registration |
|
156 | - */ |
|
157 | - public function match_current_display_name( $user_id ) { |
|
158 | - |
|
159 | - $user = get_userdata( $user_id ); |
|
160 | - |
|
161 | - $names = $this->generate_display_names( $user ); |
|
162 | - |
|
163 | - $format = array_search( $user->display_name, $names, true ); |
|
164 | - |
|
165 | - // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
|
166 | - // trigger last resort method at the 'gform_user_updated' hook |
|
167 | - if( false === $format || 'nickname' === $format ) { |
|
168 | - $this->_user_before_update = $user; |
|
169 | - $format = 'nickname'; |
|
170 | - } |
|
171 | - |
|
172 | - return $format; |
|
173 | - |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Generate an array of all the user display names possibilities |
|
178 | - * |
|
179 | - * @since 1.15 |
|
180 | - * |
|
181 | - * @param object $profileuser WP_User object |
|
182 | - * @return array List all the possible display names for a certain User object |
|
183 | - */ |
|
184 | - public function generate_display_names( $profileuser ) { |
|
185 | - |
|
186 | - $public_display = array(); |
|
187 | - $public_display['nickname'] = $profileuser->nickname; |
|
188 | - $public_display['username'] = $profileuser->user_login; |
|
189 | - |
|
190 | - if ( !empty($profileuser->first_name) ) |
|
191 | - $public_display['firstname'] = $profileuser->first_name; |
|
192 | - |
|
193 | - if ( !empty($profileuser->last_name) ) |
|
194 | - $public_display['lastname'] = $profileuser->last_name; |
|
195 | - |
|
196 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
197 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
198 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
199 | - } |
|
200 | - |
|
201 | - $public_display = array_map( 'trim', $public_display ); |
|
202 | - $public_display = array_unique( $public_display ); |
|
203 | - |
|
204 | - return $public_display; |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
210 | - * |
|
211 | - * @see GFUser::update_user() |
|
212 | - * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
213 | - * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
214 | - * @param array $entry The Gravity Forms entry that was just updated |
|
215 | - * @param string $password User password |
|
216 | - * @return void |
|
217 | - */ |
|
218 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
219 | - |
|
220 | - /** |
|
221 | - * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
222 | - * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
223 | - * @since 1.14.4 |
|
224 | - * @param boolean $restore_display_name Restore Display Name? Default: true |
|
225 | - */ |
|
226 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
227 | - |
|
228 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
229 | - |
|
230 | - /** |
|
231 | - * Don't restore display name: |
|
232 | - * - either disabled, |
|
233 | - * - or it is an Update feed (we only care about Create feed) |
|
234 | - * - or we don't need as we found the correct format before updating user. |
|
235 | - * @since 1.14.4 |
|
236 | - */ |
|
237 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
238 | - return; |
|
239 | - } |
|
240 | - |
|
241 | - $user_after_update = get_userdata( $user_id ); |
|
242 | - |
|
243 | - $restored_user = $user_after_update; |
|
244 | - |
|
245 | - // Restore previous display_name |
|
246 | - $restored_user->display_name = $this->_user_before_update->display_name; |
|
247 | - |
|
248 | - // Don't have WP update the password. |
|
249 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
250 | - |
|
251 | - /** |
|
252 | - * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
253 | - * @since 1.14 |
|
254 | - * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
255 | - * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
256 | - * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
257 | - * @param array $entry The Gravity Forms entry that was just updated |
|
258 | - */ |
|
259 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
260 | - |
|
261 | - $updated = wp_update_user( $restored_user ); |
|
262 | - |
|
263 | - if( is_wp_error( $updated ) ) { |
|
264 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
265 | - } else { |
|
266 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
267 | - } |
|
268 | - |
|
269 | - $this->_user_before_update = null; |
|
270 | - |
|
271 | - unset( $updated, $restored_user, $user_after_update ); |
|
272 | - } |
|
128 | + } |
|
129 | + |
|
130 | + // If an Update feed, make sure the conditions are met. |
|
131 | + if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
132 | + if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
133 | + return; |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + // The priority is set to 3 so that default priority (10) will still override it |
|
138 | + add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
139 | + add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
140 | + |
|
141 | + // Trigger the User Registration update user method |
|
142 | + $gf_user_registration->update_user( $entry, $form, $config ); |
|
143 | + |
|
144 | + remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
145 | + remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
146 | + |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * Calculate the user display name format |
|
151 | + * |
|
152 | + * @since 1.15 |
|
153 | + * |
|
154 | + * @param int $user_id WP User ID |
|
155 | + * @return string Display name format as used inside Gravity Forms User Registration |
|
156 | + */ |
|
157 | + public function match_current_display_name( $user_id ) { |
|
158 | + |
|
159 | + $user = get_userdata( $user_id ); |
|
160 | + |
|
161 | + $names = $this->generate_display_names( $user ); |
|
162 | + |
|
163 | + $format = array_search( $user->display_name, $names, true ); |
|
164 | + |
|
165 | + // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
|
166 | + // trigger last resort method at the 'gform_user_updated' hook |
|
167 | + if( false === $format || 'nickname' === $format ) { |
|
168 | + $this->_user_before_update = $user; |
|
169 | + $format = 'nickname'; |
|
170 | + } |
|
171 | + |
|
172 | + return $format; |
|
173 | + |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Generate an array of all the user display names possibilities |
|
178 | + * |
|
179 | + * @since 1.15 |
|
180 | + * |
|
181 | + * @param object $profileuser WP_User object |
|
182 | + * @return array List all the possible display names for a certain User object |
|
183 | + */ |
|
184 | + public function generate_display_names( $profileuser ) { |
|
185 | + |
|
186 | + $public_display = array(); |
|
187 | + $public_display['nickname'] = $profileuser->nickname; |
|
188 | + $public_display['username'] = $profileuser->user_login; |
|
189 | + |
|
190 | + if ( !empty($profileuser->first_name) ) |
|
191 | + $public_display['firstname'] = $profileuser->first_name; |
|
192 | + |
|
193 | + if ( !empty($profileuser->last_name) ) |
|
194 | + $public_display['lastname'] = $profileuser->last_name; |
|
195 | + |
|
196 | + if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
197 | + $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
198 | + $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
199 | + } |
|
200 | + |
|
201 | + $public_display = array_map( 'trim', $public_display ); |
|
202 | + $public_display = array_unique( $public_display ); |
|
203 | + |
|
204 | + return $public_display; |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
210 | + * |
|
211 | + * @see GFUser::update_user() |
|
212 | + * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
213 | + * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
214 | + * @param array $entry The Gravity Forms entry that was just updated |
|
215 | + * @param string $password User password |
|
216 | + * @return void |
|
217 | + */ |
|
218 | + public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
219 | + |
|
220 | + /** |
|
221 | + * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
222 | + * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
223 | + * @since 1.14.4 |
|
224 | + * @param boolean $restore_display_name Restore Display Name? Default: true |
|
225 | + */ |
|
226 | + $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
227 | + |
|
228 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
229 | + |
|
230 | + /** |
|
231 | + * Don't restore display name: |
|
232 | + * - either disabled, |
|
233 | + * - or it is an Update feed (we only care about Create feed) |
|
234 | + * - or we don't need as we found the correct format before updating user. |
|
235 | + * @since 1.14.4 |
|
236 | + */ |
|
237 | + if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
238 | + return; |
|
239 | + } |
|
240 | + |
|
241 | + $user_after_update = get_userdata( $user_id ); |
|
242 | + |
|
243 | + $restored_user = $user_after_update; |
|
244 | + |
|
245 | + // Restore previous display_name |
|
246 | + $restored_user->display_name = $this->_user_before_update->display_name; |
|
247 | + |
|
248 | + // Don't have WP update the password. |
|
249 | + unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
250 | + |
|
251 | + /** |
|
252 | + * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
253 | + * @since 1.14 |
|
254 | + * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
255 | + * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
256 | + * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
257 | + * @param array $entry The Gravity Forms entry that was just updated |
|
258 | + */ |
|
259 | + $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
260 | + |
|
261 | + $updated = wp_update_user( $restored_user ); |
|
262 | + |
|
263 | + if( is_wp_error( $updated ) ) { |
|
264 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
265 | + } else { |
|
266 | + do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
267 | + } |
|
268 | + |
|
269 | + $this->_user_before_update = null; |
|
270 | + |
|
271 | + unset( $updated, $restored_user, $user_after_update ); |
|
272 | + } |
|
273 | 273 | |
274 | 274 | } //end class |
@@ -28,13 +28,13 @@ |
||
28 | 28 | |
29 | 29 | $show_mt = $this->show_merge_tags(); |
30 | 30 | |
31 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
32 | - $class .= ' merge-tag-support mt-position-right '; |
|
31 | + if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
32 | + $class .= ' merge-tag-support mt-position-right '; |
|
33 | 33 | |
34 | - if( empty( $this->field['show_all_fields'] ) ) { |
|
35 | - $class .= ' mt-hide_all_fields '; |
|
36 | - } |
|
37 | - } |
|
34 | + if( empty( $this->field['show_all_fields'] ) ) { |
|
35 | + $class .= ' mt-hide_all_fields '; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | $class .= rgar( $this->field, 'class' ); |
39 | 39 | $placeholder = rgar( $this->field, 'placeholder' ); |
40 | 40 | ?> |