@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | die; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
| 19 | +if ( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
| 20 | 20 | require( GRAVITYVIEW_DIR . 'includes/lib/class-gamajo-template-loader.php' ); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | 'atts' => NULL, |
| 158 | 158 | ) ); |
| 159 | 159 | |
| 160 | - foreach ($atts as $key => $value) { |
|
| 161 | - if( is_null( $value ) ) { |
|
| 160 | + foreach ( $atts as $key => $value ) { |
|
| 161 | + if ( is_null( $value ) ) { |
|
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | $this->{$key} = $value; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | static function getInstance( $passed_post = NULL ) { |
| 191 | 191 | |
| 192 | - if( empty( self::$instance ) ) { |
|
| 192 | + if ( empty( self::$instance ) ) { |
|
| 193 | 193 | self::$instance = new self( $passed_post ); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function getCurrentField( $key = NULL ) { |
| 204 | 204 | |
| 205 | - if( !empty( $key ) ) { |
|
| 206 | - if( isset( $this->_current_field[ $key ] ) ) { |
|
| 205 | + if ( ! empty( $key ) ) { |
|
| 206 | + if ( isset( $this->_current_field[ $key ] ) ) { |
|
| 207 | 207 | return $this->_current_field[ $key ]; |
| 208 | 208 | } |
| 209 | 209 | return NULL; |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | public function setCurrentFieldSetting( $key, $value ) { |
| 216 | 216 | |
| 217 | - if( !empty( $this->_current_field ) ) { |
|
| 218 | - $this->_current_field['field_settings'][ $key ] = $value; |
|
| 217 | + if ( ! empty( $this->_current_field ) ) { |
|
| 218 | + $this->_current_field[ 'field_settings' ][ $key ] = $value; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | public function getCurrentFieldSetting( $key ) { |
| 224 | - $settings = $this->getCurrentField('field_settings'); |
|
| 224 | + $settings = $this->getCurrentField( 'field_settings' ); |
|
| 225 | 225 | |
| 226 | - if( $settings && !empty( $settings[ $key ] ) ) { |
|
| 226 | + if ( $settings && ! empty( $settings[ $key ] ) ) { |
|
| 227 | 227 | return $settings[ $key ]; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | public function getAtts( $key = NULL ) { |
| 256 | 256 | |
| 257 | - if( !empty( $key ) ) { |
|
| 258 | - if( isset( $this->atts[ $key ] ) ) { |
|
| 257 | + if ( ! empty( $key ) ) { |
|
| 258 | + if ( isset( $this->atts[ $key ] ) ) { |
|
| 259 | 259 | return $this->atts[ $key ]; |
| 260 | 260 | } |
| 261 | 261 | return NULL; |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | $fields = empty( $this->fields ) ? NULL : $this->fields; |
| 323 | 323 | |
| 324 | - if( $fields && !empty( $key ) ) { |
|
| 324 | + if ( $fields && ! empty( $key ) ) { |
|
| 325 | 325 | $fields = isset( $fields[ $key ] ) ? $fields[ $key ] : NULL; |
| 326 | 326 | } |
| 327 | 327 | |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function getField( $key ) { |
| 343 | 343 | |
| 344 | - if( !empty( $key ) ) { |
|
| 345 | - if( isset( $this->fields[ $key ] ) ) { |
|
| 344 | + if ( ! empty( $key ) ) { |
|
| 345 | + if ( isset( $this->fields[ $key ] ) ) { |
|
| 346 | 346 | return $this->fields[ $key ]; |
| 347 | 347 | } |
| 348 | 348 | } |
@@ -442,8 +442,8 @@ discard block |
||
| 442 | 442 | public function getPaginationCounts() { |
| 443 | 443 | |
| 444 | 444 | $paging = $this->getPaging(); |
| 445 | - $offset = $paging['offset']; |
|
| 446 | - $page_size = $paging['page_size']; |
|
| 445 | + $offset = $paging[ 'offset' ]; |
|
| 446 | + $page_size = $paging[ 'page_size' ]; |
|
| 447 | 447 | $total = $this->getTotalEntries(); |
| 448 | 448 | |
| 449 | 449 | if ( empty( $total ) ) { |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | list( $first, $last, $total ) = apply_filters( 'gravityview_pagination_counts', array( $first, $last, $total ) ); |
| 466 | 466 | |
| 467 | - return array( 'first' => (int) $first, 'last' => (int) $last, 'total' => (int) $total ); |
|
| 467 | + return array( 'first' => (int)$first, 'last' => (int)$last, 'total' => (int)$total ); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -548,16 +548,16 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | public function getCurrentEntry() { |
| 550 | 550 | |
| 551 | - if( in_array( $this->getContext(), array( 'edit', 'single') ) ) { |
|
| 551 | + if ( in_array( $this->getContext(), array( 'edit', 'single' ) ) ) { |
|
| 552 | 552 | $entries = $this->getEntries(); |
| 553 | - $entry = $entries[0]; |
|
| 553 | + $entry = $entries[ 0 ]; |
|
| 554 | 554 | } else { |
| 555 | 555 | $entry = $this->_current_entry; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** @since 1.16 Fixes DataTables empty entry issue */ |
| 559 | - if ( empty( $entry ) && ! empty( $this->_current_field['entry'] ) ) { |
|
| 560 | - $entry = $this->_current_field['entry']; |
|
| 559 | + if ( empty( $entry ) && ! empty( $this->_current_field[ 'entry' ] ) ) { |
|
| 560 | + $entry = $this->_current_field[ 'entry' ]; |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | return $entry; |
@@ -591,8 +591,8 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | public function renderZone( $zone = '', $atts = array() ) { |
| 593 | 593 | |
| 594 | - if( empty( $zone ) ) { |
|
| 595 | - do_action('gravityview_log_error', 'GravityView_View[renderZone] No zone defined.'); |
|
| 594 | + if ( empty( $zone ) ) { |
|
| 595 | + do_action( 'gravityview_log_error', 'GravityView_View[renderZone] No zone defined.' ); |
|
| 596 | 596 | return NULL; |
| 597 | 597 | } |
| 598 | 598 | |
@@ -601,33 +601,33 @@ discard block |
||
| 601 | 601 | 'context' => $this->getContext(), |
| 602 | 602 | 'entry' => $this->getCurrentEntry(), |
| 603 | 603 | 'form' => $this->getForm(), |
| 604 | - 'hide_empty' => $this->getAtts('hide_empty'), |
|
| 604 | + 'hide_empty' => $this->getAtts( 'hide_empty' ), |
|
| 605 | 605 | ); |
| 606 | 606 | |
| 607 | 607 | $final_atts = wp_parse_args( $atts, $defaults ); |
| 608 | 608 | |
| 609 | 609 | $output = ''; |
| 610 | 610 | |
| 611 | - $final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}"; |
|
| 611 | + $final_atts[ 'zone_id' ] = "{$final_atts[ 'context' ]}_{$final_atts[ 'slug' ]}-{$zone}"; |
|
| 612 | 612 | |
| 613 | - $fields = $this->getField( $final_atts['zone_id'] ); |
|
| 613 | + $fields = $this->getField( $final_atts[ 'zone_id' ] ); |
|
| 614 | 614 | |
| 615 | 615 | // Backward compatibility |
| 616 | - if( 'table' === $this->getTemplatePartSlug() ) { |
|
| 616 | + if ( 'table' === $this->getTemplatePartSlug() ) { |
|
| 617 | 617 | /** |
| 618 | 618 | * Modify the fields displayed in the table |
| 619 | 619 | * @var array |
| 620 | 620 | */ |
| 621 | - $fields = apply_filters("gravityview_table_cells", $fields, $this ); |
|
| 621 | + $fields = apply_filters( "gravityview_table_cells", $fields, $this ); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - if( empty( $fields ) ) { |
|
| 624 | + if ( empty( $fields ) ) { |
|
| 625 | 625 | return NULL; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | $field_output = ''; |
| 629 | 629 | foreach ( $fields as $field ) { |
| 630 | - $final_atts['field'] = $field; |
|
| 630 | + $final_atts[ 'field' ] = $field; |
|
| 631 | 631 | |
| 632 | 632 | $field_output .= gravityview_field_output( $final_atts ); |
| 633 | 633 | } |
@@ -638,17 +638,17 @@ discard block |
||
| 638 | 638 | * @since 1.7.6 |
| 639 | 639 | * @param boolean $hide_empty_zone Default: false |
| 640 | 640 | */ |
| 641 | - if( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
| 641 | + if ( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
| 642 | 642 | return NULL; |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 646 | - $output .= '<div class="'.gravityview_sanitize_html_class( $final_atts['wrapper_class'] ).'">'; |
|
| 645 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 646 | + $output .= '<div class="' . gravityview_sanitize_html_class( $final_atts[ 'wrapper_class' ] ) . '">'; |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | $output .= $field_output; |
| 650 | 650 | |
| 651 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 651 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 652 | 652 | $output .= '</div>'; |
| 653 | 653 | } |
| 654 | 654 | |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | */ |
| 669 | 669 | function locate_template( $template_names, $load = false, $require_once = true ) { |
| 670 | 670 | |
| 671 | - if( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 671 | + if ( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 672 | 672 | |
| 673 | 673 | $located = $this->located_templates[ $template_names ]; |
| 674 | 674 | |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | // Set $load to always false so we handle it here. |
| 678 | 678 | $located = parent::locate_template( $template_names, false, $require_once ); |
| 679 | 679 | |
| 680 | - if( is_string( $template_names ) ) { |
|
| 680 | + if ( is_string( $template_names ) ) { |
|
| 681 | 681 | $this->located_templates[ $template_names ] = $located; |
| 682 | 682 | } |
| 683 | 683 | } |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | * @return mixed|null The stored data. |
| 696 | 696 | */ |
| 697 | 697 | public function __get( $name ) { |
| 698 | - if( isset( $this->{$name} ) ) { |
|
| 698 | + if ( isset( $this->{$name} ) ) { |
|
| 699 | 699 | return $this->{$name}; |
| 700 | 700 | } else { |
| 701 | 701 | return NULL; |
@@ -724,15 +724,15 @@ discard block |
||
| 724 | 724 | $additional = array(); |
| 725 | 725 | |
| 726 | 726 | // form-19-table-body.php |
| 727 | - $additional[] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 727 | + $additional[ ] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 728 | 728 | |
| 729 | 729 | // view-3-table-body.php |
| 730 | - $additional[] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
| 730 | + $additional[ ] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
| 731 | 731 | |
| 732 | - if( $this->getPostId() ) { |
|
| 732 | + if ( $this->getPostId() ) { |
|
| 733 | 733 | |
| 734 | 734 | // page-19-table-body.php |
| 735 | - $additional[] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 735 | + $additional[ ] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | // Combine with existing table-body.php and table.php |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | |
| 755 | 755 | do_action( 'gravityview_log_debug', '[render] Rendering Template File', $template_file ); |
| 756 | 756 | |
| 757 | - if( !empty( $template_file) ) { |
|
| 757 | + if ( ! empty( $template_file ) ) { |
|
| 758 | 758 | |
| 759 | 759 | if ( $require_once ) { |
| 760 | 760 | require_once( $template_file ); |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | */ |
| 772 | 772 | public function render_widget_hooks( $view_id ) { |
| 773 | 773 | |
| 774 | - if( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
| 774 | + if ( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
| 775 | 775 | do_action( 'gravityview_log_debug', __METHOD__ . ' - Not rendering widgets; single entry' ); |
| 776 | 776 | return; |
| 777 | 777 | } |
@@ -779,9 +779,9 @@ discard block |
||
| 779 | 779 | $view_data = gravityview_get_current_view_data( $view_id ); |
| 780 | 780 | |
| 781 | 781 | // get View widget configuration |
| 782 | - $widgets = (array)$view_data['widgets']; |
|
| 782 | + $widgets = (array)$view_data[ 'widgets' ]; |
|
| 783 | 783 | |
| 784 | - switch( current_filter() ) { |
|
| 784 | + switch ( current_filter() ) { |
|
| 785 | 785 | default: |
| 786 | 786 | case 'gravityview_before': |
| 787 | 787 | $zone = 'header'; |
@@ -795,9 +795,9 @@ discard block |
||
| 795 | 795 | * Filter widgets not in the current zone |
| 796 | 796 | * @since 1.16 |
| 797 | 797 | */ |
| 798 | - foreach( $widgets as $key => $widget ) { |
|
| 798 | + foreach ( $widgets as $key => $widget ) { |
|
| 799 | 799 | // The widget isn't in the current zone |
| 800 | - if( false === strpos( $key, $zone ) ) { |
|
| 800 | + if ( false === strpos( $key, $zone ) ) { |
|
| 801 | 801 | unset( $widgets[ $key ] ); |
| 802 | 802 | } |
| 803 | 803 | } |
@@ -812,8 +812,8 @@ discard block |
||
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | // Prevent being called twice |
| 815 | - if( did_action( $zone.'_'.$view_id.'_widgets' ) ) { |
|
| 816 | - do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__ , $zone.'_'.$view_id.'_widgets' ) ); |
|
| 815 | + if ( did_action( $zone . '_' . $view_id . '_widgets' ) ) { |
|
| 816 | + do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__, $zone . '_' . $view_id . '_widgets' ) ); |
|
| 817 | 817 | return; |
| 818 | 818 | } |
| 819 | 819 | |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | * @param string $zone Current widget zone, either `header` or `footer` |
| 830 | 830 | * @param array $widgets Array of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']` |
| 831 | 831 | */ |
| 832 | - $css_class = apply_filters('gravityview/widgets/wrapper_css_class', 'gv-grid gv-widgets-' . $zone, $zone, $widgets ); |
|
| 832 | + $css_class = apply_filters( 'gravityview/widgets/wrapper_css_class', 'gv-grid gv-widgets-' . $zone, $zone, $widgets ); |
|
| 833 | 833 | |
| 834 | 834 | $css_class = gravityview_sanitize_html_class( $css_class ); |
| 835 | 835 | |
@@ -837,17 +837,17 @@ discard block |
||
| 837 | 837 | ?> |
| 838 | 838 | <div class="<?php echo $css_class; ?>"> |
| 839 | 839 | <?php |
| 840 | - foreach( $rows as $row ) { |
|
| 841 | - foreach( $row as $col => $areas ) { |
|
| 842 | - $column = ($col == '2-2') ? '1-2 gv-right' : $col.' gv-left'; |
|
| 840 | + foreach ( $rows as $row ) { |
|
| 841 | + foreach ( $row as $col => $areas ) { |
|
| 842 | + $column = ( $col == '2-2' ) ? '1-2 gv-right' : $col . ' gv-left'; |
|
| 843 | 843 | ?> |
| 844 | 844 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
| 845 | 845 | <?php |
| 846 | - if( !empty( $areas ) ) { |
|
| 847 | - foreach( $areas as $area ) { |
|
| 848 | - if( !empty( $widgets[ $zone .'_'. $area['areaid'] ] ) ) { |
|
| 849 | - foreach( $widgets[ $zone .'_'. $area['areaid'] ] as $widget ) { |
|
| 850 | - do_action( "gravityview_render_widget_{$widget['id']}", $widget ); |
|
| 846 | + if ( ! empty( $areas ) ) { |
|
| 847 | + foreach ( $areas as $area ) { |
|
| 848 | + if ( ! empty( $widgets[ $zone . '_' . $area[ 'areaid' ] ] ) ) { |
|
| 849 | + foreach ( $widgets[ $zone . '_' . $area[ 'areaid' ] ] as $widget ) { |
|
| 850 | + do_action( "gravityview_render_widget_{$widget[ 'id' ]}", $widget ); |
|
| 851 | 851 | } |
| 852 | 852 | } |
| 853 | 853 | } |
@@ -863,8 +863,8 @@ discard block |
||
| 863 | 863 | * Prevent widgets from being called twice. |
| 864 | 864 | * Checking for loop_start prevents themes and plugins that pre-process shortcodes from triggering the action before displaying. Like, ahem, the Divi theme and WordPress SEO plugin |
| 865 | 865 | */ |
| 866 | - if( did_action( 'loop_start' ) ) { |
|
| 867 | - do_action( $zone.'_'.$view_id.'_widgets' ); |
|
| 866 | + if ( did_action( 'loop_start' ) ) { |
|
| 867 | + do_action( $zone . '_' . $view_id . '_widgets' ); |
|
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
@@ -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,254 +22,254 @@ 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 | |
| 41 | - /** |
|
| 42 | - * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
| 43 | - * @since 1.11 |
|
| 44 | - * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
| 45 | - */ |
|
| 46 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
| 47 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
| 48 | - |
|
| 49 | - // last resort in case the current user display name don't match any of the defaults |
|
| 50 | - add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Update the WordPress user profile based on the GF User Registration create feed |
|
| 56 | - * |
|
| 57 | - * @since 1.11 |
|
| 58 | - * |
|
| 59 | - * @param array $form Gravity Forms form array |
|
| 60 | - * @param string $entry_id Gravity Forms entry ID |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public function update_user( $form = array(), $entry_id = 0 ) { |
|
| 64 | - |
|
| 65 | - if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) { |
|
| 66 | - return; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - // support for GF User Registration 3.x |
|
| 70 | - $gf_user_3 = class_exists('GF_User_Registration') ? true : false; |
|
| 71 | - |
|
| 72 | - if( $gf_user_3 ) { |
|
| 73 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $entry = GFAPI::get_entry( $entry_id ); |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
| 80 | - * @since 1.11 |
|
| 81 | - * @param array $entry Gravity Forms entry |
|
| 82 | - * @param array $form Gravity Forms form |
|
| 83 | - */ |
|
| 84 | - $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @since 1.14 |
|
| 88 | - */ |
|
| 89 | - if( $gf_user_3 ) { |
|
| 90 | - $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
| 91 | - } else { |
|
| 92 | - $config = GFUser::get_active_config( $form, $entry ); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
| 98 | - * @since 1.15 |
|
| 99 | - * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
| 100 | - * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
| 101 | - * @param[in] array $form Gravity Forms form array |
|
| 102 | - * @param[in] array $entry Gravity Forms entry being edited |
|
| 103 | - */ |
|
| 104 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
| 105 | - |
|
| 106 | - if( $preserve_role ) { |
|
| 107 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Make sure the current display name is not changed with the update user method. |
|
| 112 | - * @since 1.15 |
|
| 113 | - */ |
|
| 114 | - $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
| 119 | - * @since 1.14 |
|
| 120 | - * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
| 121 | - * @param[in] array $form Gravity Forms form array |
|
| 122 | - * @param[in] array $entry Gravity Forms entry being edited |
|
| 123 | - */ |
|
| 124 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
| 125 | - |
|
| 126 | - $is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' ); |
|
| 127 | - |
|
| 128 | - // Only update if it's a create feed |
|
| 129 | - if( ! $is_create_feed ) { |
|
| 130 | - return; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // The priority is set to 3 so that default priority (10) will still override it |
|
| 134 | - add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 135 | - add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 136 | - |
|
| 137 | - // Trigger the User Registration update user method |
|
| 138 | - if( $gf_user_3 ) { |
|
| 139 | - $gf_user_registration->update_user( $entry, $form, $config ); |
|
| 140 | - } else { |
|
| 141 | - GFUser::update_user( $entry, $form, $config ); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 146 | - remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 147 | - |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Calculate the user display name format |
|
| 152 | - * |
|
| 153 | - * @since 1.15 |
|
| 154 | - * |
|
| 155 | - * @param int $user_id WP User ID |
|
| 156 | - * @return string Display name format as used inside Gravity Forms User Registration |
|
| 157 | - */ |
|
| 158 | - public function match_current_display_name( $user_id ) { |
|
| 159 | - |
|
| 160 | - $user = get_userdata( $user_id ); |
|
| 161 | - |
|
| 162 | - $names = $this->generate_display_names( $user ); |
|
| 163 | - |
|
| 164 | - $format = array_search( $user->display_name, $names, true ); |
|
| 165 | - |
|
| 166 | - // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
|
| 167 | - // trigger last resort method at the 'gform_user_updated' hook |
|
| 168 | - if( false === $format || 'nickname' === $format ) { |
|
| 169 | - $this->_user_before_update = $user; |
|
| 170 | - $format = 'nickname'; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return $format; |
|
| 174 | - |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Generate an array of all the user display names possibilities |
|
| 179 | - * |
|
| 180 | - * @since 1.15 |
|
| 181 | - * |
|
| 182 | - * @param object $profileuser WP_User object |
|
| 183 | - * @return array List all the possible display names for a certain User object |
|
| 184 | - */ |
|
| 185 | - public function generate_display_names( $profileuser ) { |
|
| 186 | - |
|
| 187 | - $public_display = array(); |
|
| 188 | - $public_display['nickname'] = $profileuser->nickname; |
|
| 189 | - $public_display['username'] = $profileuser->user_login; |
|
| 190 | - |
|
| 191 | - if ( !empty($profileuser->first_name) ) |
|
| 192 | - $public_display['firstname'] = $profileuser->first_name; |
|
| 193 | - |
|
| 194 | - if ( !empty($profileuser->last_name) ) |
|
| 195 | - $public_display['lastname'] = $profileuser->last_name; |
|
| 196 | - |
|
| 197 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 198 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 199 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - $public_display = array_map( 'trim', $public_display ); |
|
| 203 | - $public_display = array_unique( $public_display ); |
|
| 204 | - |
|
| 205 | - return $public_display; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
| 211 | - * |
|
| 212 | - * @see GFUser::update_user() |
|
| 213 | - * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
| 214 | - * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
| 215 | - * @param array $entry The Gravity Forms entry that was just updated |
|
| 216 | - * @param string $password User password |
|
| 217 | - * @return void |
|
| 218 | - */ |
|
| 219 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
| 223 | - * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
| 224 | - * @since 1.14.4 |
|
| 225 | - * @param boolean $restore_display_name Restore Display Name? Default: true |
|
| 226 | - */ |
|
| 227 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
| 228 | - |
|
| 229 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Don't restore display name: |
|
| 233 | - * - either disabled, |
|
| 234 | - * - or it is an Update feed (we only care about Create feed) |
|
| 235 | - * - or we don't need as we found the correct format before updating user. |
|
| 236 | - * @since 1.14.4 |
|
| 237 | - */ |
|
| 238 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 239 | - return; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - $user_after_update = get_userdata( $user_id ); |
|
| 243 | - |
|
| 244 | - $restored_user = $user_after_update; |
|
| 245 | - |
|
| 246 | - // Restore previous display_name |
|
| 247 | - $restored_user->display_name = $this->_user_before_update->display_name; |
|
| 248 | - |
|
| 249 | - // Don't have WP update the password. |
|
| 250 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
| 254 | - * @since 1.14 |
|
| 255 | - * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
| 256 | - * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
| 257 | - * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
| 258 | - * @param array $entry The Gravity Forms entry that was just updated |
|
| 259 | - */ |
|
| 260 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
| 261 | - |
|
| 262 | - $updated = wp_update_user( $restored_user ); |
|
| 263 | - |
|
| 264 | - if( is_wp_error( $updated ) ) { |
|
| 265 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 266 | - } else { |
|
| 267 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - $this->_user_before_update = null; |
|
| 271 | - |
|
| 272 | - unset( $updated, $restored_user, $user_after_update ); |
|
| 273 | - } |
|
| 41 | + /** |
|
| 42 | + * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
| 43 | + * @since 1.11 |
|
| 44 | + * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
| 45 | + */ |
|
| 46 | + if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
| 47 | + add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
| 48 | + |
|
| 49 | + // last resort in case the current user display name don't match any of the defaults |
|
| 50 | + add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Update the WordPress user profile based on the GF User Registration create feed |
|
| 56 | + * |
|
| 57 | + * @since 1.11 |
|
| 58 | + * |
|
| 59 | + * @param array $form Gravity Forms form array |
|
| 60 | + * @param string $entry_id Gravity Forms entry ID |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public function update_user( $form = array(), $entry_id = 0 ) { |
|
| 64 | + |
|
| 65 | + if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) { |
|
| 66 | + return; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + // support for GF User Registration 3.x |
|
| 70 | + $gf_user_3 = class_exists('GF_User_Registration') ? true : false; |
|
| 71 | + |
|
| 72 | + if( $gf_user_3 ) { |
|
| 73 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $entry = GFAPI::get_entry( $entry_id ); |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
| 80 | + * @since 1.11 |
|
| 81 | + * @param array $entry Gravity Forms entry |
|
| 82 | + * @param array $form Gravity Forms form |
|
| 83 | + */ |
|
| 84 | + $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @since 1.14 |
|
| 88 | + */ |
|
| 89 | + if( $gf_user_3 ) { |
|
| 90 | + $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
| 91 | + } else { |
|
| 92 | + $config = GFUser::get_active_config( $form, $entry ); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
| 98 | + * @since 1.15 |
|
| 99 | + * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
| 100 | + * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
| 101 | + * @param[in] array $form Gravity Forms form array |
|
| 102 | + * @param[in] array $entry Gravity Forms entry being edited |
|
| 103 | + */ |
|
| 104 | + $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
| 105 | + |
|
| 106 | + if( $preserve_role ) { |
|
| 107 | + $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Make sure the current display name is not changed with the update user method. |
|
| 112 | + * @since 1.15 |
|
| 113 | + */ |
|
| 114 | + $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
| 119 | + * @since 1.14 |
|
| 120 | + * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
| 121 | + * @param[in] array $form Gravity Forms form array |
|
| 122 | + * @param[in] array $entry Gravity Forms entry being edited |
|
| 123 | + */ |
|
| 124 | + $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
| 125 | + |
|
| 126 | + $is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' ); |
|
| 127 | + |
|
| 128 | + // Only update if it's a create feed |
|
| 129 | + if( ! $is_create_feed ) { |
|
| 130 | + return; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // The priority is set to 3 so that default priority (10) will still override it |
|
| 134 | + add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 135 | + add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 136 | + |
|
| 137 | + // Trigger the User Registration update user method |
|
| 138 | + if( $gf_user_3 ) { |
|
| 139 | + $gf_user_registration->update_user( $entry, $form, $config ); |
|
| 140 | + } else { |
|
| 141 | + GFUser::update_user( $entry, $form, $config ); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 146 | + remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 147 | + |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Calculate the user display name format |
|
| 152 | + * |
|
| 153 | + * @since 1.15 |
|
| 154 | + * |
|
| 155 | + * @param int $user_id WP User ID |
|
| 156 | + * @return string Display name format as used inside Gravity Forms User Registration |
|
| 157 | + */ |
|
| 158 | + public function match_current_display_name( $user_id ) { |
|
| 159 | + |
|
| 160 | + $user = get_userdata( $user_id ); |
|
| 161 | + |
|
| 162 | + $names = $this->generate_display_names( $user ); |
|
| 163 | + |
|
| 164 | + $format = array_search( $user->display_name, $names, true ); |
|
| 165 | + |
|
| 166 | + // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
|
| 167 | + // trigger last resort method at the 'gform_user_updated' hook |
|
| 168 | + if( false === $format || 'nickname' === $format ) { |
|
| 169 | + $this->_user_before_update = $user; |
|
| 170 | + $format = 'nickname'; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return $format; |
|
| 174 | + |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Generate an array of all the user display names possibilities |
|
| 179 | + * |
|
| 180 | + * @since 1.15 |
|
| 181 | + * |
|
| 182 | + * @param object $profileuser WP_User object |
|
| 183 | + * @return array List all the possible display names for a certain User object |
|
| 184 | + */ |
|
| 185 | + public function generate_display_names( $profileuser ) { |
|
| 186 | + |
|
| 187 | + $public_display = array(); |
|
| 188 | + $public_display['nickname'] = $profileuser->nickname; |
|
| 189 | + $public_display['username'] = $profileuser->user_login; |
|
| 190 | + |
|
| 191 | + if ( !empty($profileuser->first_name) ) |
|
| 192 | + $public_display['firstname'] = $profileuser->first_name; |
|
| 193 | + |
|
| 194 | + if ( !empty($profileuser->last_name) ) |
|
| 195 | + $public_display['lastname'] = $profileuser->last_name; |
|
| 196 | + |
|
| 197 | + if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 198 | + $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 199 | + $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + $public_display = array_map( 'trim', $public_display ); |
|
| 203 | + $public_display = array_unique( $public_display ); |
|
| 204 | + |
|
| 205 | + return $public_display; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
| 211 | + * |
|
| 212 | + * @see GFUser::update_user() |
|
| 213 | + * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
| 214 | + * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
| 215 | + * @param array $entry The Gravity Forms entry that was just updated |
|
| 216 | + * @param string $password User password |
|
| 217 | + * @return void |
|
| 218 | + */ |
|
| 219 | + public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
| 223 | + * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
| 224 | + * @since 1.14.4 |
|
| 225 | + * @param boolean $restore_display_name Restore Display Name? Default: true |
|
| 226 | + */ |
|
| 227 | + $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
| 228 | + |
|
| 229 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Don't restore display name: |
|
| 233 | + * - either disabled, |
|
| 234 | + * - or it is an Update feed (we only care about Create feed) |
|
| 235 | + * - or we don't need as we found the correct format before updating user. |
|
| 236 | + * @since 1.14.4 |
|
| 237 | + */ |
|
| 238 | + if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 239 | + return; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + $user_after_update = get_userdata( $user_id ); |
|
| 243 | + |
|
| 244 | + $restored_user = $user_after_update; |
|
| 245 | + |
|
| 246 | + // Restore previous display_name |
|
| 247 | + $restored_user->display_name = $this->_user_before_update->display_name; |
|
| 248 | + |
|
| 249 | + // Don't have WP update the password. |
|
| 250 | + unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
| 254 | + * @since 1.14 |
|
| 255 | + * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
| 256 | + * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
| 257 | + * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
| 258 | + * @param array $entry The Gravity Forms entry that was just updated |
|
| 259 | + */ |
|
| 260 | + $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
| 261 | + |
|
| 262 | + $updated = wp_update_user( $restored_user ); |
|
| 263 | + |
|
| 264 | + if( is_wp_error( $updated ) ) { |
|
| 265 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 266 | + } else { |
|
| 267 | + do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + $this->_user_before_update = null; |
|
| 271 | + |
|
| 272 | + unset( $updated, $restored_user, $user_after_update ); |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | } //end class |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * @since 1.11 |
| 44 | 44 | * @param boolean $boolean Whether to trigger update on user registration (default: true) |
| 45 | 45 | */ |
| 46 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
| 47 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
| 46 | + if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
| 47 | + add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 ); |
|
| 48 | 48 | |
| 49 | 49 | // last resort in case the current user display name don't match any of the defaults |
| 50 | 50 | add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function update_user( $form = array(), $entry_id = 0 ) { |
| 64 | 64 | |
| 65 | - if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) { |
|
| 65 | + if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GFUser' ) || empty( $entry_id ) ) { |
|
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // support for GF User Registration 3.x |
| 70 | - $gf_user_3 = class_exists('GF_User_Registration') ? true : false; |
|
| 70 | + $gf_user_3 = class_exists( 'GF_User_Registration' ) ? true : false; |
|
| 71 | 71 | |
| 72 | - if( $gf_user_3 ) { |
|
| 72 | + if ( $gf_user_3 ) { |
|
| 73 | 73 | $gf_user_registration = GF_User_Registration::get_instance(); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | /** |
| 87 | 87 | * @since 1.14 |
| 88 | 88 | */ |
| 89 | - if( $gf_user_3 ) { |
|
| 89 | + if ( $gf_user_3 ) { |
|
| 90 | 90 | $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
| 91 | 91 | } else { |
| 92 | 92 | $config = GFUser::get_active_config( $form, $entry ); |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
| 105 | 105 | |
| 106 | - if( $preserve_role ) { |
|
| 107 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 106 | + if ( $preserve_role ) { |
|
| 107 | + $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role'; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * Make sure the current display name is not changed with the update user method. |
| 112 | 112 | * @since 1.15 |
| 113 | 113 | */ |
| 114 | - $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
| 114 | + $config[ 'meta' ][ 'displayname' ] = $this->match_current_display_name( $entry[ 'created_by' ] ); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
| 125 | 125 | |
| 126 | - $is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' ); |
|
| 126 | + $is_create_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'create' ); |
|
| 127 | 127 | |
| 128 | 128 | // Only update if it's a create feed |
| 129 | - if( ! $is_create_feed ) { |
|
| 129 | + if ( ! $is_create_feed ) { |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | add_filter( 'send_email_change_email', '__return_false', 3 ); |
| 136 | 136 | |
| 137 | 137 | // Trigger the User Registration update user method |
| 138 | - if( $gf_user_3 ) { |
|
| 138 | + if ( $gf_user_3 ) { |
|
| 139 | 139 | $gf_user_registration->update_user( $entry, $form, $config ); |
| 140 | 140 | } else { |
| 141 | 141 | GFUser::update_user( $entry, $form, $config ); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
| 167 | 167 | // trigger last resort method at the 'gform_user_updated' hook |
| 168 | - if( false === $format || 'nickname' === $format ) { |
|
| 168 | + if ( false === $format || 'nickname' === $format ) { |
|
| 169 | 169 | $this->_user_before_update = $user; |
| 170 | 170 | $format = 'nickname'; |
| 171 | 171 | } |
@@ -185,18 +185,18 @@ discard block |
||
| 185 | 185 | public function generate_display_names( $profileuser ) { |
| 186 | 186 | |
| 187 | 187 | $public_display = array(); |
| 188 | - $public_display['nickname'] = $profileuser->nickname; |
|
| 189 | - $public_display['username'] = $profileuser->user_login; |
|
| 188 | + $public_display[ 'nickname' ] = $profileuser->nickname; |
|
| 189 | + $public_display[ 'username' ] = $profileuser->user_login; |
|
| 190 | 190 | |
| 191 | - if ( !empty($profileuser->first_name) ) |
|
| 192 | - $public_display['firstname'] = $profileuser->first_name; |
|
| 191 | + if ( ! empty( $profileuser->first_name ) ) |
|
| 192 | + $public_display[ 'firstname' ] = $profileuser->first_name; |
|
| 193 | 193 | |
| 194 | - if ( !empty($profileuser->last_name) ) |
|
| 195 | - $public_display['lastname'] = $profileuser->last_name; |
|
| 194 | + if ( ! empty( $profileuser->last_name ) ) |
|
| 195 | + $public_display[ 'lastname' ] = $profileuser->last_name; |
|
| 196 | 196 | |
| 197 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 198 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 199 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 197 | + if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) { |
|
| 198 | + $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 199 | + $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $public_display = array_map( 'trim', $public_display ); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
| 228 | 228 | |
| 229 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 229 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' ); |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Don't restore display name: |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * - or we don't need as we found the correct format before updating user. |
| 236 | 236 | * @since 1.14.4 |
| 237 | 237 | */ |
| 238 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 238 | + if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $updated = wp_update_user( $restored_user ); |
| 263 | 263 | |
| 264 | - if( is_wp_error( $updated ) ) { |
|
| 265 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 264 | + if ( is_wp_error( $updated ) ) { |
|
| 265 | + do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 266 | 266 | } else { |
| 267 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 267 | + do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | $this->_user_before_update = null; |
@@ -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 | - if( class_exists( 'GFUser' ) || class_exists( 'GF_User_Registration' ) ) { |
|
| 48 | - $this->load_components( 'user-registration' ); |
|
| 49 | - } |
|
| 46 | + // If GF User Registration Add-on exists |
|
| 47 | + if( class_exists( 'GFUser' ) || class_exists( 'GF_User_Registration' ) ) { |
|
| 48 | + $this->load_components( 'user-registration' ); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $this->add_hooks(); |
|
| 51 | + $this->add_hooks(); |
|
| 52 | 52 | |
| 53 | 53 | // Process hooks for addons that may or may not be present |
| 54 | 54 | $this->addon_specific_hooks(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
| 58 | - static function getInstance() { |
|
| 58 | + static function getInstance() { |
|
| 59 | 59 | |
| 60 | - if( empty( self::$instance ) ) { |
|
| 61 | - self::$instance = new GravityView_Edit_Entry; |
|
| 62 | - } |
|
| 60 | + if( empty( self::$instance ) ) { |
|
| 61 | + self::$instance = new GravityView_Edit_Entry; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return self::$instance; |
|
| 65 | - } |
|
| 64 | + return self::$instance; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | - private function load_components( $component ) { |
|
| 68 | + private function load_components( $component ) { |
|
| 69 | 69 | |
| 70 | - $dir = trailingslashit( self::$file ); |
|
| 70 | + $dir = trailingslashit( self::$file ); |
|
| 71 | 71 | |
| 72 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 73 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 72 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 73 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 74 | 74 | |
| 75 | - // Loads component and pass extension's instance so that component can |
|
| 76 | - // talk each other. |
|
| 77 | - require_once $filename; |
|
| 78 | - $this->instances[ $component ] = new $classname( $this ); |
|
| 79 | - $this->instances[ $component ]->load(); |
|
| 75 | + // Loads component and pass extension's instance so that component can |
|
| 76 | + // talk each other. |
|
| 77 | + require_once $filename; |
|
| 78 | + $this->instances[ $component ] = new $classname( $this ); |
|
| 79 | + $this->instances[ $component ]->load(); |
|
| 80 | 80 | |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - private function add_hooks() { |
|
| 83 | + private function add_hooks() { |
|
| 84 | 84 | |
| 85 | - // Add front-end access to Gravity Forms delete file action |
|
| 86 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 85 | + // Add front-end access to Gravity Forms delete file action |
|
| 86 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 87 | 87 | |
| 88 | - // Make sure this hook is run for non-admins |
|
| 89 | - add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 88 | + // Make sure this hook is run for non-admins |
|
| 89 | + add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 90 | 90 | |
| 91 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 91 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 92 | 92 | |
| 93 | - // add template path to check for field |
|
| 94 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 93 | + // add template path to check for field |
|
| 94 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 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 |
@@ -107,75 +107,75 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Include this extension templates path |
|
| 112 | - * @param array $file_paths List of template paths ordered |
|
| 113 | - */ |
|
| 114 | - public function add_template_path( $file_paths ) { |
|
| 115 | - |
|
| 116 | - // Index 100 is the default GravityView template path. |
|
| 117 | - $file_paths[ 110 ] = self::$file; |
|
| 118 | - |
|
| 119 | - return $file_paths; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * |
|
| 124 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 125 | - * |
|
| 126 | - * @param $view_id int GravityView view id |
|
| 127 | - * @param $form_id int Gravity Forms form id |
|
| 128 | - * @param $entry_id int Gravity Forms entry id |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 132 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * The edit entry link creates a secure link with a nonce |
|
| 138 | - * |
|
| 139 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 140 | - * it formats the display of the edit form like it does in the backend, like |
|
| 141 | - * "You can edit this post from the post page" fields, for example. |
|
| 142 | - * |
|
| 143 | - * @param $entry array Gravity Forms entry object |
|
| 144 | - * @param $view_id int GravityView view id |
|
| 145 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 146 | - * @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/ } |
|
| 147 | - * @return string |
|
| 148 | - */ |
|
| 149 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 150 | - |
|
| 151 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 152 | - |
|
| 153 | - $base = gv_entry_link( $entry, $post_id ); |
|
| 154 | - |
|
| 155 | - $url = add_query_arg( array( |
|
| 156 | - 'page' => 'gf_entries', // Needed for GFForms::get_page() |
|
| 157 | - 'view' => 'entry', // Needed for GFForms::get_page() |
|
| 158 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
| 159 | - ), $base ); |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Allow passing params to dynamically populate entry with values |
|
| 163 | - * @since 1.9.2 |
|
| 164 | - */ |
|
| 165 | - if( !empty( $field_values ) ) { |
|
| 166 | - |
|
| 167 | - if( is_array( $field_values ) ) { |
|
| 168 | - // If already an array, no parse_str() needed |
|
| 169 | - $params = $field_values; |
|
| 170 | - } else { |
|
| 171 | - parse_str( $field_values, $params ); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - $url = add_query_arg( $params, $url ); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - return $url; |
|
| 178 | - } |
|
| 110 | + /** |
|
| 111 | + * Include this extension templates path |
|
| 112 | + * @param array $file_paths List of template paths ordered |
|
| 113 | + */ |
|
| 114 | + public function add_template_path( $file_paths ) { |
|
| 115 | + |
|
| 116 | + // Index 100 is the default GravityView template path. |
|
| 117 | + $file_paths[ 110 ] = self::$file; |
|
| 118 | + |
|
| 119 | + return $file_paths; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * |
|
| 124 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 125 | + * |
|
| 126 | + * @param $view_id int GravityView view id |
|
| 127 | + * @param $form_id int Gravity Forms form id |
|
| 128 | + * @param $entry_id int Gravity Forms entry id |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 132 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * The edit entry link creates a secure link with a nonce |
|
| 138 | + * |
|
| 139 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 140 | + * it formats the display of the edit form like it does in the backend, like |
|
| 141 | + * "You can edit this post from the post page" fields, for example. |
|
| 142 | + * |
|
| 143 | + * @param $entry array Gravity Forms entry object |
|
| 144 | + * @param $view_id int GravityView view id |
|
| 145 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 146 | + * @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/ } |
|
| 147 | + * @return string |
|
| 148 | + */ |
|
| 149 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 150 | + |
|
| 151 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 152 | + |
|
| 153 | + $base = gv_entry_link( $entry, $post_id ); |
|
| 154 | + |
|
| 155 | + $url = add_query_arg( array( |
|
| 156 | + 'page' => 'gf_entries', // Needed for GFForms::get_page() |
|
| 157 | + 'view' => 'entry', // Needed for GFForms::get_page() |
|
| 158 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
| 159 | + ), $base ); |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Allow passing params to dynamically populate entry with values |
|
| 163 | + * @since 1.9.2 |
|
| 164 | + */ |
|
| 165 | + if( !empty( $field_values ) ) { |
|
| 166 | + |
|
| 167 | + if( is_array( $field_values ) ) { |
|
| 168 | + // If already an array, no parse_str() needed |
|
| 169 | + $params = $field_values; |
|
| 170 | + } else { |
|
| 171 | + parse_str( $field_values, $params ); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + $url = add_query_arg( $params, $url ); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + return $url; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -211,81 +211,81 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * checks if user has permissions to edit a specific entry |
|
| 216 | - * |
|
| 217 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 218 | - * |
|
| 219 | - * @param array $entry Gravity Forms entry array |
|
| 220 | - * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
| 221 | - * @return bool |
|
| 222 | - */ |
|
| 223 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
| 214 | + /** |
|
| 215 | + * checks if user has permissions to edit a specific entry |
|
| 216 | + * |
|
| 217 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 218 | + * |
|
| 219 | + * @param array $entry Gravity Forms entry array |
|
| 220 | + * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
| 221 | + * @return bool |
|
| 222 | + */ |
|
| 223 | + public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
| 224 | 224 | |
| 225 | - // No permission by default |
|
| 226 | - $user_can_edit = false; |
|
| 225 | + // No permission by default |
|
| 226 | + $user_can_edit = false; |
|
| 227 | 227 | |
| 228 | - // If they can edit any entries (as defined in Gravity Forms) |
|
| 229 | - // Or if they can edit other people's entries |
|
| 230 | - // Then we're good. |
|
| 231 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 228 | + // If they can edit any entries (as defined in Gravity Forms) |
|
| 229 | + // Or if they can edit other people's entries |
|
| 230 | + // Then we're good. |
|
| 231 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 232 | 232 | |
| 233 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
| 233 | + do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
| 234 | 234 | |
| 235 | - $user_can_edit = true; |
|
| 235 | + $user_can_edit = true; |
|
| 236 | 236 | |
| 237 | - } else if( !isset( $entry['created_by'] ) ) { |
|
| 237 | + } else if( !isset( $entry['created_by'] ) ) { |
|
| 238 | 238 | |
| 239 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
| 239 | + do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
| 240 | 240 | |
| 241 | - $user_can_edit = false; |
|
| 241 | + $user_can_edit = false; |
|
| 242 | 242 | |
| 243 | - } else { |
|
| 243 | + } else { |
|
| 244 | 244 | |
| 245 | - // get user_edit setting |
|
| 246 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
| 247 | - // if View ID not specified or is the current view |
|
| 248 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
| 249 | - } else { |
|
| 250 | - // in case is specified and not the current view |
|
| 251 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
| 252 | - } |
|
| 245 | + // get user_edit setting |
|
| 246 | + if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
| 247 | + // if View ID not specified or is the current view |
|
| 248 | + $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
| 249 | + } else { |
|
| 250 | + // in case is specified and not the current view |
|
| 251 | + $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - $current_user = wp_get_current_user(); |
|
| 254 | + $current_user = wp_get_current_user(); |
|
| 255 | 255 | |
| 256 | - // User edit is disabled |
|
| 257 | - if( empty( $user_edit ) ) { |
|
| 256 | + // User edit is disabled |
|
| 257 | + if( empty( $user_edit ) ) { |
|
| 258 | 258 | |
| 259 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
| 259 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
| 260 | 260 | |
| 261 | - $user_can_edit = false; |
|
| 262 | - } |
|
| 261 | + $user_can_edit = false; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 265 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 264 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 265 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 266 | 266 | |
| 267 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
| 267 | + do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
| 268 | 268 | |
| 269 | - $user_can_edit = true; |
|
| 269 | + $user_can_edit = true; |
|
| 270 | 270 | |
| 271 | - } else if( ! is_user_logged_in() ) { |
|
| 271 | + } else if( ! is_user_logged_in() ) { |
|
| 272 | 272 | |
| 273 | - do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
| 274 | - } |
|
| 273 | + do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - } |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - /** |
|
| 279 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 280 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 281 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 282 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 283 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 284 | - */ |
|
| 285 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 278 | + /** |
|
| 279 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 280 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 281 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 282 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 283 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 284 | + */ |
|
| 285 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 286 | 286 | |
| 287 | - return (bool)$user_can_edit; |
|
| 288 | - } |
|
| 287 | + return (bool)$user_can_edit; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | 290 | |
| 291 | 291 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | self::$file = plugin_dir_path( __FILE__ ); |
| 38 | 38 | |
| 39 | - if( is_admin() ) { |
|
| 39 | + if ( is_admin() ) { |
|
| 40 | 40 | $this->load_components( 'admin' ); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $this->load_components( 'render' ); |
| 45 | 45 | |
| 46 | 46 | // If GF User Registration Add-on exists |
| 47 | - if( class_exists( 'GFUser' ) || class_exists( 'GF_User_Registration' ) ) { |
|
| 47 | + if ( class_exists( 'GFUser' ) || class_exists( 'GF_User_Registration' ) ) { |
|
| 48 | 48 | $this->load_components( 'user-registration' ); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | static function getInstance() { |
| 59 | 59 | |
| 60 | - if( empty( self::$instance ) ) { |
|
| 60 | + if ( empty( self::$instance ) ) { |
|
| 61 | 61 | self::$instance = new GravityView_Edit_Entry; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | private function add_hooks() { |
| 84 | 84 | |
| 85 | 85 | // Add front-end access to Gravity Forms delete file action |
| 86 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 86 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file' ) ); |
|
| 87 | 87 | |
| 88 | 88 | // Make sure this hook is run for non-admins |
| 89 | - add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 89 | + add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file' ) ); |
|
| 90 | 90 | |
| 91 | 91 | add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
| 92 | 92 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function addon_specific_hooks() { |
| 103 | 103 | |
| 104 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
| 105 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
| 104 | + if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
| 105 | + add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) ); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
| 150 | 150 | |
| 151 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 151 | + $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] ); |
|
| 152 | 152 | |
| 153 | 153 | $base = gv_entry_link( $entry, $post_id ); |
| 154 | 154 | |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | * Allow passing params to dynamically populate entry with values |
| 163 | 163 | * @since 1.9.2 |
| 164 | 164 | */ |
| 165 | - if( !empty( $field_values ) ) { |
|
| 165 | + if ( ! empty( $field_values ) ) { |
|
| 166 | 166 | |
| 167 | - if( is_array( $field_values ) ) { |
|
| 167 | + if ( is_array( $field_values ) ) { |
|
| 168 | 168 | // If already an array, no parse_str() needed |
| 169 | 169 | $params = $field_values; |
| 170 | 170 | } else { |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public function modify_field_blacklist( $fields = array(), $context = NULL ) { |
| 188 | 188 | |
| 189 | - if( empty( $context ) || $context !== 'edit' ) { |
|
| 189 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
| 190 | 190 | return $fields; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -228,24 +228,24 @@ discard block |
||
| 228 | 228 | // If they can edit any entries (as defined in Gravity Forms) |
| 229 | 229 | // Or if they can edit other people's entries |
| 230 | 230 | // Then we're good. |
| 231 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 231 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) { |
|
| 232 | 232 | |
| 233 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
| 233 | + do_action( 'gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.' ); |
|
| 234 | 234 | |
| 235 | 235 | $user_can_edit = true; |
| 236 | 236 | |
| 237 | - } else if( !isset( $entry['created_by'] ) ) { |
|
| 237 | + } else if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
| 238 | 238 | |
| 239 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
| 239 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.' ); |
|
| 240 | 240 | |
| 241 | 241 | $user_can_edit = false; |
| 242 | 242 | |
| 243 | 243 | } else { |
| 244 | 244 | |
| 245 | 245 | // get user_edit setting |
| 246 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
| 246 | + if ( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
| 247 | 247 | // if View ID not specified or is the current view |
| 248 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
| 248 | + $user_edit = GravityView_View::getInstance()->getAtts( 'user_edit' ); |
|
| 249 | 249 | } else { |
| 250 | 250 | // in case is specified and not the current view |
| 251 | 251 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
@@ -254,21 +254,21 @@ discard block |
||
| 254 | 254 | $current_user = wp_get_current_user(); |
| 255 | 255 | |
| 256 | 256 | // User edit is disabled |
| 257 | - if( empty( $user_edit ) ) { |
|
| 257 | + if ( empty( $user_edit ) ) { |
|
| 258 | 258 | |
| 259 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
| 259 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
| 260 | 260 | |
| 261 | 261 | $user_can_edit = false; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
| 265 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 265 | + else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
| 266 | 266 | |
| 267 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
| 267 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
| 268 | 268 | |
| 269 | 269 | $user_can_edit = true; |
| 270 | 270 | |
| 271 | - } else if( ! is_user_logged_in() ) { |
|
| 271 | + } else if ( ! is_user_logged_in() ) { |
|
| 272 | 272 | |
| 273 | 273 | do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
| 274 | 274 | } |
@@ -30,29 +30,29 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $label = ''; |
| 32 | 32 | |
| 33 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
| 33 | + if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) { |
|
| 34 | 34 | |
| 35 | - $label = $field['label']; |
|
| 35 | + $label = $field[ 'label' ]; |
|
| 36 | 36 | |
| 37 | 37 | // Support Gravity Forms 1.9+ |
| 38 | - if( class_exists( 'GF_Field' ) ) { |
|
| 38 | + if ( class_exists( 'GF_Field' ) ) { |
|
| 39 | 39 | |
| 40 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
| 40 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
| 41 | 41 | |
| 42 | - if( $field_object ) { |
|
| 42 | + if ( $field_object ) { |
|
| 43 | 43 | |
| 44 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
| 44 | + $input = GFFormsModel::get_input( $field_object, $field[ 'id' ] ); |
|
| 45 | 45 | |
| 46 | 46 | // This is a complex field, with labels on a per-input basis |
| 47 | - if( $input ) { |
|
| 47 | + if ( $input ) { |
|
| 48 | 48 | |
| 49 | 49 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
| 50 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
| 50 | + $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ]; |
|
| 51 | 51 | |
| 52 | 52 | } else { |
| 53 | 53 | |
| 54 | 54 | // This is a field with one label |
| 55 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
| 55 | + $label = $field_object->get_field_label( true, $field[ 'label' ] ); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
| 64 | - if ( !empty( $field['custom_label'] ) ) { |
|
| 64 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
| 65 | 65 | |
| 66 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
| 66 | + $label = self::replace_variables( $field[ 'custom_label' ], $form, $entry ); |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | $width = NULL; |
| 119 | 119 | |
| 120 | - if( !empty( $field['width'] ) ) { |
|
| 121 | - $width = absint( $field['width'] ); |
|
| 120 | + if ( ! empty( $field[ 'width' ] ) ) { |
|
| 121 | + $width = absint( $field[ 'width' ] ); |
|
| 122 | 122 | |
| 123 | 123 | // If using percentages, limit to 100% |
| 124 | - if( '%d%%' === $format && $width > 100 ) { |
|
| 124 | + if ( '%d%%' === $format && $width > 100 ) { |
|
| 125 | 125 | $width = 100; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -144,39 +144,39 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $classes = array(); |
| 146 | 146 | |
| 147 | - if( !empty( $field['custom_class'] ) ) { |
|
| 147 | + if ( ! empty( $field[ 'custom_class' ] ) ) { |
|
| 148 | 148 | |
| 149 | - $custom_class = $field['custom_class']; |
|
| 149 | + $custom_class = $field[ 'custom_class' ]; |
|
| 150 | 150 | |
| 151 | - if( !empty( $entry ) ) { |
|
| 151 | + if ( ! empty( $entry ) ) { |
|
| 152 | 152 | |
| 153 | 153 | // We want the merge tag to be formatted as a class. The merge tag may be |
| 154 | 154 | // replaced by a multiple-word value that should be output as a single class. |
| 155 | 155 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
| 156 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 156 | + add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
| 157 | 157 | |
| 158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 158 | + $custom_class = self::replace_variables( $custom_class, $form, $entry ); |
|
| 159 | 159 | |
| 160 | 160 | // And then we want life to return to normal |
| 161 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 161 | + remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // And now we want the spaces to be handled nicely. |
| 165 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
| 165 | + $classes[ ] = gravityview_sanitize_html_class( $custom_class ); |
|
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if(!empty($field['id'])) { |
|
| 170 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
| 171 | - $form_id = '-'.$form['id']; |
|
| 169 | + if ( ! empty( $field[ 'id' ] ) ) { |
|
| 170 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
| 171 | + $form_id = '-' . $form[ 'id' ]; |
|
| 172 | 172 | } else { |
| 173 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
| 173 | + $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
|
| 176 | + $classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - return esc_attr(implode(' ', $classes)); |
|
| 179 | + return esc_attr( implode( ' ', $classes ) ); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -193,16 +193,16 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
| 195 | 195 | $gravityview_view = GravityView_View::getInstance(); |
| 196 | - $id = $field['id']; |
|
| 196 | + $id = $field[ 'id' ]; |
|
| 197 | 197 | |
| 198 | 198 | if ( ! empty( $id ) ) { |
| 199 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
| 200 | - $form_id = '-' . $form['id']; |
|
| 199 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
| 200 | + $form_id = '-' . $form[ 'id' ]; |
|
| 201 | 201 | } else { |
| 202 | 202 | $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
| 205 | + $id = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | return esc_attr( $id ); |
@@ -219,13 +219,13 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public static function field_value( $entry, $field_settings, $format = 'html' ) { |
| 221 | 221 | |
| 222 | - if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
| 222 | + if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) { |
|
| 223 | 223 | return NULL; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
| 227 | 227 | |
| 228 | - if( class_exists( 'GFCache' ) ) { |
|
| 228 | + if ( class_exists( 'GFCache' ) ) { |
|
| 229 | 229 | /** |
| 230 | 230 | * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run. |
| 231 | 231 | * |
@@ -240,46 +240,46 @@ discard block |
||
| 240 | 240 | * @param boolean false Tell Gravity Forms not to store this as a transient |
| 241 | 241 | * @param int 0 Time to store the value. 0 is maximum amount of time possible. |
| 242 | 242 | */ |
| 243 | - GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0 ); |
|
| 243 | + GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry[ "id" ] . "_" . $field_settings[ "id" ], false, false, 0 ); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $field_id = $field_settings['id']; |
|
| 246 | + $field_id = $field_settings[ 'id' ]; |
|
| 247 | 247 | |
| 248 | 248 | $form = $gravityview_view->getForm(); |
| 249 | 249 | |
| 250 | 250 | $field = gravityview_get_field( $form, $field_id ); |
| 251 | 251 | |
| 252 | - $field_type = RGFormsModel::get_input_type($field); |
|
| 252 | + $field_type = RGFormsModel::get_input_type( $field ); |
|
| 253 | 253 | |
| 254 | - if( $field_type ) { |
|
| 255 | - $field_type = $field['type']; |
|
| 256 | - $value = RGFormsModel::get_lead_field_value($entry, $field); |
|
| 254 | + if ( $field_type ) { |
|
| 255 | + $field_type = $field[ 'type' ]; |
|
| 256 | + $value = RGFormsModel::get_lead_field_value( $entry, $field ); |
|
| 257 | 257 | } else { |
| 258 | 258 | // For non-integer field types (`id`, `date_created`, etc.) |
| 259 | 259 | $field_type = $field_id; |
| 260 | - $field['type'] = $field_id; |
|
| 261 | - $value = isset($entry[$field_type]) ? $entry[$field_type] : NULL; |
|
| 260 | + $field[ 'type' ] = $field_id; |
|
| 261 | + $value = isset( $entry[ $field_type ] ) ? $entry[ $field_type ] : NULL; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // Prevent any PHP warnings that may be generated |
| 265 | 265 | ob_start(); |
| 266 | 266 | |
| 267 | - $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format); |
|
| 267 | + $display_value = GFCommon::get_lead_field_display( $field, $value, $entry[ "currency" ], false, $format ); |
|
| 268 | 268 | |
| 269 | - if( $errors = ob_get_clean() ) { |
|
| 269 | + if ( $errors = ob_get_clean() ) { |
|
| 270 | 270 | do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors ); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form); |
|
| 273 | + $display_value = apply_filters( "gform_entry_field_value", $display_value, $field, $entry, $form ); |
|
| 274 | 274 | |
| 275 | 275 | // prevent the use of merge_tags for non-admin fields |
| 276 | - if( !empty( $field['adminOnly'] ) ) { |
|
| 276 | + if ( ! empty( $field[ 'adminOnly' ] ) ) { |
|
| 277 | 277 | $display_value = self::replace_variables( $display_value, $form, $entry ); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // Check whether the field exists in /includes/fields/{$field_type}.php |
| 281 | 281 | // This can be overridden by user template files. |
| 282 | - $field_path = $gravityview_view->locate_template("fields/{$field_type}.php"); |
|
| 282 | + $field_path = $gravityview_view->locate_template( "fields/{$field_type}.php" ); |
|
| 283 | 283 | |
| 284 | 284 | // Set the field data to be available in the templates |
| 285 | 285 | $gravityview_view->setCurrentField( array( |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | 'entry' => $entry, |
| 294 | 294 | 'field_type' => $field_type, /** {@since 1.6} */ |
| 295 | 295 | 'field_path' => $field_path, /** {@since 1.16} */ |
| 296 | - )); |
|
| 296 | + ) ); |
|
| 297 | 297 | |
| 298 | - if( ! empty( $field_path ) ) { |
|
| 298 | + if ( ! empty( $field_path ) ) { |
|
| 299 | 299 | |
| 300 | - do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) ); |
|
| 300 | + do_action( 'gravityview_log_debug', sprintf( '[field_value] Rendering %s', $field_path ) ); |
|
| 301 | 301 | |
| 302 | 302 | ob_start(); |
| 303 | 303 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $field_settings = $gravityview_view->getCurrentField('field_settings'); |
|
| 315 | + $field_settings = $gravityview_view->getCurrentField( 'field_settings' ); |
|
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | 318 | * @filter `gravityview_field_entry_value_{$field_type}_pre_link` Modify the field value output for a field type before Show As Link setting is applied. Example: `gravityview_field_entry_value_number_pre_link` |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. |
| 331 | 331 | * |
| 332 | 332 | */ |
| 333 | - if( !empty( $field_settings['show_as_link'] ) && ! gv_empty( $output, false, false ) ) { |
|
| 333 | + if ( ! empty( $field_settings[ 'show_as_link' ] ) && ! gv_empty( $output, false, false ) ) { |
|
| 334 | 334 | |
| 335 | - $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' ); |
|
| 335 | + $link_atts = empty( $field_settings[ 'new_window' ] ) ? array() : array( 'target' => '_blank' ); |
|
| 336 | 336 | |
| 337 | 337 | $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings ); |
| 338 | 338 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @param array $field_settings Settings for the particular GV field |
| 347 | 347 | * @param array $field Current field being displayed |
| 348 | 348 | */ |
| 349 | - $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 349 | + $output = apply_filters( 'gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * @filter `gravityview_field_entry_value` Modify the field value output for all field types |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) { |
| 373 | 373 | |
| 374 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
| 374 | + if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) { |
|
| 375 | 375 | |
| 376 | 376 | do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry ); |
| 377 | 377 | |
@@ -399,19 +399,19 @@ discard block |
||
| 399 | 399 | * @param boolean $wpautop Apply wpautop() to the output? |
| 400 | 400 | * @return string HTML of "no results" text |
| 401 | 401 | */ |
| 402 | - public static function no_results($wpautop = true) { |
|
| 402 | + public static function no_results( $wpautop = true ) { |
|
| 403 | 403 | $gravityview_view = GravityView_View::getInstance(); |
| 404 | 404 | |
| 405 | 405 | $is_search = false; |
| 406 | 406 | |
| 407 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
| 407 | + if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
| 408 | 408 | $is_search = true; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if($is_search) { |
|
| 412 | - $output = __('This search returned no results.', 'gravityview'); |
|
| 411 | + if ( $is_search ) { |
|
| 412 | + $output = __( 'This search returned no results.', 'gravityview' ); |
|
| 413 | 413 | } else { |
| 414 | - $output = __('No entries match your request.', 'gravityview'); |
|
| 414 | + $output = __( 'No entries match your request.', 'gravityview' ); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
@@ -419,9 +419,9 @@ discard block |
||
| 419 | 419 | * @param string $output The existing "No Entries" text |
| 420 | 420 | * @param boolean $is_search Is the current page a search result, or just a multiple entries screen? |
| 421 | 421 | */ |
| 422 | - $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search); |
|
| 422 | + $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search ); |
|
| 423 | 423 | |
| 424 | - return $wpautop ? wpautop($output) : $output; |
|
| 424 | + return $wpautop ? wpautop( $output ) : $output; |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
@@ -438,37 +438,37 @@ discard block |
||
| 438 | 438 | |
| 439 | 439 | $gravityview_view = GravityView_View::getInstance(); |
| 440 | 440 | |
| 441 | - if( empty( $post_id ) ) { |
|
| 441 | + if ( empty( $post_id ) ) { |
|
| 442 | 442 | |
| 443 | 443 | $post_id = false; |
| 444 | 444 | |
| 445 | 445 | // DataTables passes the Post ID |
| 446 | - if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
| 446 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 447 | 447 | |
| 448 | - $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false; |
|
| 448 | + $post_id = isset( $_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : false; |
|
| 449 | 449 | |
| 450 | 450 | } else { |
| 451 | 451 | |
| 452 | 452 | // The Post ID has been passed via the shortcode |
| 453 | - if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
| 453 | + if ( ! empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
| 454 | 454 | |
| 455 | 455 | $post_id = $gravityview_view->getPostId(); |
| 456 | 456 | |
| 457 | 457 | } else { |
| 458 | 458 | |
| 459 | 459 | // This is a GravityView post type |
| 460 | - if( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
| 460 | + if ( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
| 461 | 461 | |
| 462 | 462 | $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID; |
| 463 | 463 | |
| 464 | 464 | } else { |
| 465 | 465 | |
| 466 | 466 | // This is an embedded GravityView; use the embedded post's ID as the base. |
| 467 | - if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
| 467 | + if ( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
| 468 | 468 | |
| 469 | 469 | $post_id = $post->ID; |
| 470 | 470 | |
| 471 | - } elseif( $gravityview_view->getViewId() ) { |
|
| 471 | + } elseif ( $gravityview_view->getViewId() ) { |
|
| 472 | 472 | |
| 473 | 473 | // The GravityView has been embedded in a widget or in a template, and |
| 474 | 474 | // is not in the current content. Thus, we defer to the View's own ID. |
@@ -483,36 +483,36 @@ discard block |
||
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | // No post ID, get outta here. |
| 486 | - if( empty( $post_id ) ) { |
|
| 486 | + if ( empty( $post_id ) ) { |
|
| 487 | 487 | return NULL; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | // If we've saved the permalink in memory, use it |
| 491 | 491 | // @since 1.3 |
| 492 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
| 492 | + $link = wp_cache_get( 'gv_directory_link_' . $post_id ); |
|
| 493 | 493 | |
| 494 | - if( empty( $link ) ) { |
|
| 494 | + if ( empty( $link ) ) { |
|
| 495 | 495 | |
| 496 | 496 | $link = get_permalink( $post_id ); |
| 497 | 497 | |
| 498 | 498 | // If not yet saved, cache the permalink. |
| 499 | 499 | // @since 1.3 |
| 500 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
| 500 | + wp_cache_set( 'gv_directory_link_' . $post_id, $link ); |
|
| 501 | 501 | |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | // Deal with returning to proper pagination for embedded views |
| 505 | - if( $link && $add_query_args ) { |
|
| 505 | + if ( $link && $add_query_args ) { |
|
| 506 | 506 | |
| 507 | 507 | $args = array(); |
| 508 | 508 | |
| 509 | - if( $pagenum = rgget('pagenum') ) { |
|
| 510 | - $args['pagenum'] = intval( $pagenum ); |
|
| 509 | + if ( $pagenum = rgget( 'pagenum' ) ) { |
|
| 510 | + $args[ 'pagenum' ] = intval( $pagenum ); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - if( $sort = rgget('sort') ) { |
|
| 514 | - $args['sort'] = $sort; |
|
| 515 | - $args['dir'] = rgget('dir'); |
|
| 513 | + if ( $sort = rgget( 'sort' ) ) { |
|
| 514 | + $args[ 'sort' ] = $sort; |
|
| 515 | + $args[ 'dir' ] = rgget( 'dir' ); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | $link = add_query_arg( $args, $link ); |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | private static function get_custom_entry_slug( $id, $entry = array() ) { |
| 536 | 536 | |
| 537 | 537 | // Generate an unique hash to use as the default value |
| 538 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
| 538 | + $slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 ); |
|
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | 541 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
| 547 | 547 | |
| 548 | 548 | // Make sure we have something - use the original ID as backup. |
| 549 | - if( empty( $slug ) ) { |
|
| 549 | + if ( empty( $slug ) ) { |
|
| 550 | 550 | $slug = $id; |
| 551 | 551 | } |
| 552 | 552 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
| 576 | 576 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
| 577 | 577 | */ |
| 578 | - $custom = apply_filters('gravityview_custom_entry_slug', false ); |
|
| 578 | + $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 579 | 579 | |
| 580 | 580 | // If we're using custom slug... |
| 581 | 581 | if ( $custom ) { |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | // If it does have a hash set, and the hash is expected, use it. |
| 590 | 590 | // This check allows users to change the hash structure using the |
| 591 | 591 | // gravityview_entry_hash filter and have the old hashes expire. |
| 592 | - if( empty( $value ) || $value !== $hash ) { |
|
| 592 | + if ( empty( $value ) || $value !== $hash ) { |
|
| 593 | 593 | |
| 594 | 594 | gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash ); |
| 595 | 595 | |
@@ -617,12 +617,12 @@ discard block |
||
| 617 | 617 | * @param boolean $custom Should we process the custom entry slug? |
| 618 | 618 | */ |
| 619 | 619 | $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
| 620 | - if( $custom ) { |
|
| 620 | + if ( $custom ) { |
|
| 621 | 621 | // create the gravityview_unique_id and save it |
| 622 | 622 | |
| 623 | 623 | // Get the entry hash |
| 624 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 625 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
| 624 | + $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry ); |
|
| 625 | + gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash ); |
|
| 626 | 626 | |
| 627 | 627 | } |
| 628 | 628 | } |
@@ -639,14 +639,14 @@ discard block |
||
| 639 | 639 | */ |
| 640 | 640 | public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) { |
| 641 | 641 | |
| 642 | - if( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
| 642 | + if ( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
| 643 | 643 | $entry = GVCommon::get_entry( $entry ); |
| 644 | - } else if( empty( $entry ) ) { |
|
| 644 | + } else if ( empty( $entry ) ) { |
|
| 645 | 645 | $entry = GravityView_frontend::getInstance()->getEntry(); |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | // Second parameter used to be passed as $field; this makes sure it's not an array |
| 649 | - if( !is_numeric( $post_id ) ) { |
|
| 649 | + if ( ! is_numeric( $post_id ) ) { |
|
| 650 | 650 | $post_id = NULL; |
| 651 | 651 | } |
| 652 | 652 | |
@@ -654,19 +654,19 @@ discard block |
||
| 654 | 654 | $directory_link = self::directory_link( $post_id, false ); |
| 655 | 655 | |
| 656 | 656 | // No post ID? Get outta here. |
| 657 | - if( empty( $directory_link ) ) { |
|
| 657 | + if ( empty( $directory_link ) ) { |
|
| 658 | 658 | return ''; |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | $query_arg_name = GravityView_Post_Types::get_entry_var_name(); |
| 662 | 662 | |
| 663 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
| 663 | + $entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 664 | 664 | |
| 665 | - if( get_option('permalink_structure') && !is_preview() ) { |
|
| 665 | + if ( get_option( 'permalink_structure' ) && ! is_preview() ) { |
|
| 666 | 666 | |
| 667 | 667 | $args = array(); |
| 668 | 668 | |
| 669 | - $directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/'; |
|
| 669 | + $directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/' . $entry_slug . '/'; |
|
| 670 | 670 | |
| 671 | 671 | } else { |
| 672 | 672 | |
@@ -676,18 +676,18 @@ discard block |
||
| 676 | 676 | /** |
| 677 | 677 | * @since 1.7.3 |
| 678 | 678 | */ |
| 679 | - if( $add_directory_args ) { |
|
| 679 | + if ( $add_directory_args ) { |
|
| 680 | 680 | |
| 681 | - if( !empty( $_GET['pagenum'] ) ) { |
|
| 682 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
| 681 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
| 682 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /** |
| 686 | 686 | * @since 1.7 |
| 687 | 687 | */ |
| 688 | - if( $sort = rgget('sort') ) { |
|
| 689 | - $args['sort'] = $sort; |
|
| 690 | - $args['dir'] = rgget('dir'); |
|
| 688 | + if ( $sort = rgget( 'sort' ) ) { |
|
| 689 | + $args[ 'sort' ] = $sort; |
|
| 690 | + $args[ 'dir' ] = rgget( 'dir' ); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | } |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | * has the view id so that Advanced Filters can be applied correctly when rendering the single view |
| 698 | 698 | * @see GravityView_frontend::get_context_view_id() |
| 699 | 699 | */ |
| 700 | - if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
| 701 | - $args['gvid'] = gravityview_get_view_id(); |
|
| 700 | + if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
| 701 | + $args[ 'gvid' ] = gravityview_get_view_id(); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | return add_query_arg( $args, $directory_link ); |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | function gv_class( $field, $form = NULL, $entry = array() ) { |
| 719 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
| 719 | + return GravityView_API::field_class( $field, $form, $entry ); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -738,11 +738,11 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | $default_css_class = ! empty( $view_id ) ? sprintf( 'gv-container gv-container-%d', $view_id ) : 'gv-container'; |
| 740 | 740 | |
| 741 | - if( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
| 741 | + if ( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
| 742 | 742 | $default_css_class .= ' hidden'; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
| 745 | + $css_class = trim( $passed_css_class . ' ' . $default_css_class ); |
|
| 746 | 746 | |
| 747 | 747 | /** |
| 748 | 748 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | |
| 754 | 754 | $css_class = gravityview_sanitize_html_class( $css_class ); |
| 755 | 755 | |
| 756 | - if( $echo ) { |
|
| 756 | + if ( $echo ) { |
|
| 757 | 757 | echo $css_class; |
| 758 | 758 | } |
| 759 | 759 | |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | |
| 765 | 765 | $value = GravityView_API::field_value( $entry, $field ); |
| 766 | 766 | |
| 767 | - if( $value === '') { |
|
| 767 | + if ( $value === '' ) { |
|
| 768 | 768 | /** |
| 769 | 769 | * @filter `gravityview_empty_value` What to display when a field is empty |
| 770 | 770 | * @param string $value (empty string) |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | return GravityView_API::entry_link( $entry, $post_id ); |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | -function gv_no_results($wpautop = true) { |
|
| 786 | +function gv_no_results( $wpautop = true ) { |
|
| 787 | 787 | return GravityView_API::no_results( $wpautop ); |
| 788 | 788 | } |
| 789 | 789 | |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | $href = gv_directory_link(); |
| 798 | 798 | |
| 799 | - if( empty( $href ) ) { return NULL; } |
|
| 799 | + if ( empty( $href ) ) { return NULL; } |
|
| 800 | 800 | |
| 801 | 801 | // calculate link label |
| 802 | 802 | $gravityview_view = GravityView_View::getInstance(); |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | |
| 813 | 813 | $link = gravityview_get_link( $href, esc_html( $label ), array( |
| 814 | 814 | 'data-viewid' => $gravityview_view->getViewId() |
| 815 | - )); |
|
| 815 | + ) ); |
|
| 816 | 816 | |
| 817 | 817 | return $link; |
| 818 | 818 | } |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | */ |
| 832 | 832 | function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
| 833 | 833 | |
| 834 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
| 834 | + if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
| 835 | 835 | |
| 836 | 836 | // For the complete field value as generated by Gravity Forms |
| 837 | 837 | return $display_value; |
@@ -861,16 +861,16 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | $terms = explode( ', ', $value ); |
| 863 | 863 | |
| 864 | - foreach ($terms as $term_name ) { |
|
| 864 | + foreach ( $terms as $term_name ) { |
|
| 865 | 865 | |
| 866 | 866 | // If we're processing a category, |
| 867 | - if( $taxonomy === 'category' ) { |
|
| 867 | + if ( $taxonomy === 'category' ) { |
|
| 868 | 868 | |
| 869 | 869 | // Use rgexplode to prevent errors if : doesn't exist |
| 870 | 870 | list( $term_name, $term_id ) = rgexplode( ':', $value, 2 ); |
| 871 | 871 | |
| 872 | 872 | // The explode was succesful; we have the category ID |
| 873 | - if( !empty( $term_id )) { |
|
| 873 | + if ( ! empty( $term_id ) ) { |
|
| 874 | 874 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
| 875 | 875 | } else { |
| 876 | 876 | // We have to fall back to the name |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | // There's still a tag/category here. |
| 886 | - if( $term ) { |
|
| 886 | + if ( $term ) { |
|
| 887 | 887 | |
| 888 | 888 | $term_link = get_term_link( $term, $taxonomy ); |
| 889 | 889 | |
@@ -892,11 +892,11 @@ discard block |
||
| 892 | 892 | continue; |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
| 895 | + $output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - return implode(', ', $output ); |
|
| 899 | + return implode( ', ', $output ); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -910,8 +910,8 @@ discard block |
||
| 910 | 910 | |
| 911 | 911 | $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
| 912 | 912 | |
| 913 | - if( empty( $link ) ) { |
|
| 914 | - return strip_tags( $output); |
|
| 913 | + if ( empty( $link ) ) { |
|
| 914 | + return strip_tags( $output ); |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | return $output; |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | $fe = GravityView_frontend::getInstance(); |
| 931 | 931 | |
| 932 | 932 | // Solve problem when loading content via admin-ajax.php |
| 933 | - if( ! $fe->getGvOutputData() ) { |
|
| 933 | + if ( ! $fe->getGvOutputData() ) { |
|
| 934 | 934 | |
| 935 | 935 | do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' ); |
| 936 | 936 | |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | // Make 100% sure that we're dealing with a properly called situation |
| 941 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
| 941 | + if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
| 942 | 942 | |
| 943 | 943 | do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() ); |
| 944 | 944 | |
@@ -958,10 +958,10 @@ discard block |
||
| 958 | 958 | |
| 959 | 959 | $fe = GravityView_frontend::getInstance(); |
| 960 | 960 | |
| 961 | - if( ! $fe->getGvOutputData() ) { return array(); } |
|
| 961 | + if ( ! $fe->getGvOutputData() ) { return array(); } |
|
| 962 | 962 | |
| 963 | 963 | // If not set, grab the current view ID |
| 964 | - if( empty( $view_id ) ) { |
|
| 964 | + if ( empty( $view_id ) ) { |
|
| 965 | 965 | $view_id = $fe->get_context_view_id(); |
| 966 | 966 | } |
| 967 | 967 | |
@@ -1026,11 +1026,11 @@ discard block |
||
| 1026 | 1026 | */ |
| 1027 | 1027 | $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false ); |
| 1028 | 1028 | |
| 1029 | - if( $is_edit_entry ) { |
|
| 1029 | + if ( $is_edit_entry ) { |
|
| 1030 | 1030 | $context = 'edit'; |
| 1031 | - } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
| 1031 | + } else if ( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
| 1032 | 1032 | $context = 'single'; |
| 1033 | - } else if( class_exists( 'GravityView_View' ) ) { |
|
| 1033 | + } else if ( class_exists( 'GravityView_View' ) ) { |
|
| 1034 | 1034 | $context = GravityView_View::getInstance()->getContext(); |
| 1035 | 1035 | } |
| 1036 | 1036 | |
@@ -1058,12 +1058,12 @@ discard block |
||
| 1058 | 1058 | function gravityview_get_files_array( $value, $gv_class = '' ) { |
| 1059 | 1059 | /** @define "GRAVITYVIEW_DIR" "../" */ |
| 1060 | 1060 | |
| 1061 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
| 1062 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
| 1061 | + if ( ! class_exists( 'GravityView_Field' ) ) { |
|
| 1062 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
| 1066 | - include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' ); |
|
| 1065 | + if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
| 1066 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/fileupload.php' ); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | return GravityView_Field_FileUpload::get_files_array( $value, $gv_class ); |
@@ -1141,12 +1141,12 @@ discard block |
||
| 1141 | 1141 | $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args ); |
| 1142 | 1142 | |
| 1143 | 1143 | // Required fields. |
| 1144 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
| 1144 | + if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) { |
|
| 1145 | 1145 | do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args ); |
| 1146 | 1146 | return ''; |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
| 1149 | + $entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ]; |
|
| 1150 | 1150 | |
| 1151 | 1151 | /** |
| 1152 | 1152 | * Create the content variables for replacing. |
@@ -1162,37 +1162,37 @@ discard block |
||
| 1162 | 1162 | 'field_id' => '', |
| 1163 | 1163 | ); |
| 1164 | 1164 | |
| 1165 | - $context['value'] = gv_value( $entry, $args['field'] ); |
|
| 1165 | + $context[ 'value' ] = gv_value( $entry, $args[ 'field' ] ); |
|
| 1166 | 1166 | |
| 1167 | 1167 | // If the value is empty and we're hiding empty, return empty. |
| 1168 | - if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
| 1168 | + if ( $context[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) { |
|
| 1169 | 1169 | return ''; |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | - if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
| 1173 | - $context['value'] = wpautop( $context['value'] ); |
|
| 1172 | + if ( $context[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) { |
|
| 1173 | + $context[ 'value' ] = wpautop( $context[ 'value' ] ); |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | // Get width setting, if exists |
| 1177 | - $context['width'] = GravityView_API::field_width( $args['field'] ); |
|
| 1177 | + $context[ 'width' ] = GravityView_API::field_width( $args[ 'field' ] ); |
|
| 1178 | 1178 | |
| 1179 | 1179 | // If replacing with CSS inline formatting, let's do it. |
| 1180 | - $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' ); |
|
| 1180 | + $context[ 'width:style' ] = GravityView_API::field_width( $args[ 'field' ], 'width:' . $context[ 'width' ] . '%;' ); |
|
| 1181 | 1181 | |
| 1182 | 1182 | // Grab the Class using `gv_class` |
| 1183 | - $context['class'] = gv_class( $args['field'], $args['form'], $entry ); |
|
| 1184 | - $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry ); |
|
| 1183 | + $context[ 'class' ] = gv_class( $args[ 'field' ], $args[ 'form' ], $entry ); |
|
| 1184 | + $context[ 'field_id' ] = GravityView_API::field_html_attr_id( $args[ 'field' ], $args[ 'form' ], $entry ); |
|
| 1185 | 1185 | |
| 1186 | 1186 | // Get field label if needed |
| 1187 | - if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) { |
|
| 1188 | - $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] ); |
|
| 1187 | + if ( ! empty( $args[ 'label_markup' ] ) && ! empty( $args[ 'field' ][ 'show_label' ] ) ) { |
|
| 1188 | + $context[ 'label' ] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args[ 'label_markup' ] ); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | // Default Label value |
| 1192 | - $context['label_value'] = gv_label( $args['field'], $entry ); |
|
| 1192 | + $context[ 'label_value' ] = gv_label( $args[ 'field' ], $entry ); |
|
| 1193 | 1193 | |
| 1194 | - if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){ |
|
| 1195 | - $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
| 1194 | + if ( empty( $context[ 'label' ] ) && ! empty( $context[ 'label_value' ] ) ) { |
|
| 1195 | + $context[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | /** |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | * @param string $markup The HTML for the markup |
| 1202 | 1202 | * @param array $args All args for the field output |
| 1203 | 1203 | */ |
| 1204 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args ); |
|
| 1204 | + $html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args ); |
|
| 1205 | 1205 | |
| 1206 | 1206 | /** |
| 1207 | 1207 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | foreach ( $context as $tag => $value ) { |
| 1225 | 1225 | |
| 1226 | 1226 | // If the tag doesn't exist just skip it |
| 1227 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
| 1227 | + if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) { |
|
| 1228 | 1228 | continue; |
| 1229 | 1229 | } |
| 1230 | 1230 | |