Completed
Pull Request — master (#716)
by Zack
09:51 queued 04:52
created
includes/wordpress-widgets/class-gravityview-recent-entries-widget.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -184,8 +184,8 @@
 block discarded – undo
184 184
 		// Get the settings for the View ID
185 185
 		$view_settings = gravityview_get_template_settings( $instance['view_id'] );
186 186
 
187
-        // Set the context view ID to avoid conflicts with the Advanced Filter extension.
188
-        $criteria['context_view_id'] = $instance['view_id'];
187
+		// Set the context view ID to avoid conflicts with the Advanced Filter extension.
188
+		$criteria['context_view_id'] = $instance['view_id'];
189 189
 
190 190
 		$instance['limit'] = isset( $instance['limit'] ) ? $instance['limit'] : 10;
191 191
 		$view_settings['id'] = $instance['view_id'];
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-fileupload.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
 				 */
228 228
 				$content = apply_filters( 'gravityview/fields/fileupload/link_content', $content, $gravityview_view->getCurrentField() );
229 229
 
230
-                $content = gravityview_get_link( $link, $content, $link_atts );
230
+				$content = gravityview_get_link( $link, $content, $link_atts );
231 231
 			}
232 232
 
233 233
 			$output_arr[] = array(
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-textarea.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@
 block discarded – undo
21 21
 			'tooltip' => __( 'Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview' ),
22 22
 		);
23 23
 
24
-        $field_options['make_clickable'] = array(
25
-            'type' => 'checkbox',
26
-            'merge_tags' => false,
27
-            'value' => 0,
28
-            'label' => __( 'Convert text URLs to HTML links', 'gravityview' ),
29
-            'tooltip' => __( 'Converts URI, www, FTP, and email addresses in HTML links', 'gravityview' ),
30
-        );
24
+		$field_options['make_clickable'] = array(
25
+			'type' => 'checkbox',
26
+			'merge_tags' => false,
27
+			'value' => 0,
28
+			'label' => __( 'Convert text URLs to HTML links', 'gravityview' ),
29
+			'tooltip' => __( 'Converts URI, www, FTP, and email addresses in HTML links', 'gravityview' ),
30
+		);
31 31
 
32 32
 		return $field_options;
33 33
 	}
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-time.php 1 patch
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -255,7 +255,6 @@
 block discarded – undo
255 255
 	 * Get the default date format for a field based on the field ID and the time format setting
256 256
 	 *
257 257
 	 * @since 1.14
258
-
259 258
 	 * @param string $time_format The time format ("12" or "24"). Default: "12" {@since 1.14}
260 259
 	 * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14}
261 260
 	 *
Please login to merge, or discard this patch.
includes/admin/class.field.type.php 1 patch
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -10,159 +10,159 @@  discard block
 block discarded – undo
10 10
 	 *
11 11
 	 * @var string
12 12
 	 */
13
-    protected $name;
13
+	protected $name;
14 14
 
15 15
 	/**
16 16
 	 * Field settings
17 17
 	 *
18 18
 	 * @var array
19 19
 	 */
20
-    protected $field;
20
+	protected $field;
21 21
 
22 22
 	/**
23 23
 	 * Field current value
24 24
 	 *
25 25
 	 * @var mixed
26 26
 	 */
27
-    protected $value;
28
-
29
-    function __construct( $name = '', $field = array(), $curr_value = NULL ) {
30
-
31
-        $this->name = $name;
32
-
33
-        $defaults = self::get_field_defaults();
34
-
35
-        // Backward compatibility
36
-        if( !empty( $field['choices'] ) ) {
37
-        	$field['options'] = $field['choices'];
38
-        	unset( $field['choices'] );
39
-        }
40
-
41
-        $this->field =  wp_parse_args( $field, $defaults );
42
-
43
-        $this->value = is_null( $curr_value ) ? $this->field['value'] : $curr_value;
44
-
45
-    }
46
-
47
-    /**
48
-     * Returns the default details for a field option
49
-     *
50
-     * - default    // default option value, in case nothing is defined (@deprecated)
51
-     * - desc       // option description
52
-     * - value      // the option default value
53
-     * - label      // the option label
54
-     * - left_label // In case of checkboxes, left label will appear on the left of the checkbox
55
-     * - id         // the field id
56
-     * - type       // the option type ( text, checkbox, select, ... )
57
-     * - options    // when type is select, define the select options ('choices' is @deprecated)
58
-     * - merge_tags // if the option supports merge tags feature
59
-     * - class      // (new) define extra classes for the field
60
-     * - tooltip    //
61
-     *
62
-     * @return array
63
-     */
64
-    public static function get_field_defaults() {
65
-        return array(
66
-            'desc' => '',
67
-            'value' => NULL,
68
-            'label' => '',
69
-            'left_label' => NULL,
70
-            'id' => NULL,
71
-            'type'  => 'text',
72
-            'options' => NULL,
73
-            'merge_tags' => true,
74
-            'class' => '',
75
-            'tooltip' => NULL
76
-        );
77
-    }
78
-
79
-
80
-    function get_tooltip() {
81
-        if( !function_exists('gform_tooltip') ) {
82
-            return NULL;
83
-        }
84
-
85
-        return !empty( $this->field['tooltip'] ) ? ' '.gform_tooltip( $this->field['tooltip'] , false, true ) : NULL;
86
-    }
87
-
88
-    /**
89
-     * Build input id based on the name
90
-     * @return string
91
-     */
92
-    function get_field_id() {
93
-        if( isset( $this->field['id'] ) ) {
94
-            return esc_attr( $this->field['id'] );
95
-        }
96
-        return esc_attr( sanitize_html_class( $this->name ) );
97
-    }
98
-
99
-    /**
100
-     * Retrieve field label
101
-     * @return string
102
-     */
103
-    function get_field_label() {
104
-        return esc_html( trim( $this->field['label'] ) );
105
-    }
27
+	protected $value;
28
+
29
+	function __construct( $name = '', $field = array(), $curr_value = NULL ) {
30
+
31
+		$this->name = $name;
32
+
33
+		$defaults = self::get_field_defaults();
34
+
35
+		// Backward compatibility
36
+		if( !empty( $field['choices'] ) ) {
37
+			$field['options'] = $field['choices'];
38
+			unset( $field['choices'] );
39
+		}
40
+
41
+		$this->field =  wp_parse_args( $field, $defaults );
42
+
43
+		$this->value = is_null( $curr_value ) ? $this->field['value'] : $curr_value;
44
+
45
+	}
46
+
47
+	/**
48
+	 * Returns the default details for a field option
49
+	 *
50
+	 * - default    // default option value, in case nothing is defined (@deprecated)
51
+	 * - desc       // option description
52
+	 * - value      // the option default value
53
+	 * - label      // the option label
54
+	 * - left_label // In case of checkboxes, left label will appear on the left of the checkbox
55
+	 * - id         // the field id
56
+	 * - type       // the option type ( text, checkbox, select, ... )
57
+	 * - options    // when type is select, define the select options ('choices' is @deprecated)
58
+	 * - merge_tags // if the option supports merge tags feature
59
+	 * - class      // (new) define extra classes for the field
60
+	 * - tooltip    //
61
+	 *
62
+	 * @return array
63
+	 */
64
+	public static function get_field_defaults() {
65
+		return array(
66
+			'desc' => '',
67
+			'value' => NULL,
68
+			'label' => '',
69
+			'left_label' => NULL,
70
+			'id' => NULL,
71
+			'type'  => 'text',
72
+			'options' => NULL,
73
+			'merge_tags' => true,
74
+			'class' => '',
75
+			'tooltip' => NULL
76
+		);
77
+	}
78
+
79
+
80
+	function get_tooltip() {
81
+		if( !function_exists('gform_tooltip') ) {
82
+			return NULL;
83
+		}
84
+
85
+		return !empty( $this->field['tooltip'] ) ? ' '.gform_tooltip( $this->field['tooltip'] , false, true ) : NULL;
86
+	}
87
+
88
+	/**
89
+	 * Build input id based on the name
90
+	 * @return string
91
+	 */
92
+	function get_field_id() {
93
+		if( isset( $this->field['id'] ) ) {
94
+			return esc_attr( $this->field['id'] );
95
+		}
96
+		return esc_attr( sanitize_html_class( $this->name ) );
97
+	}
98
+
99
+	/**
100
+	 * Retrieve field label
101
+	 * @return string
102
+	 */
103
+	function get_field_label() {
104
+		return esc_html( trim( $this->field['label'] ) );
105
+	}
106 106
 
107 107
 	/**
108 108
 	 * Retrieve field left label
109
-     *
110
-     * @since 1.7
111
-     *
109
+	 *
110
+	 * @since 1.7
111
+	 *
112 112
 	 * @return string
113 113
 	 */
114 114
 	function get_field_left_label() {
115 115
 		return ! empty( $this->field['left_label'] ) ? esc_html( trim( $this->field['left_label'] ) ) : NULL;
116 116
 	}
117 117
 
118
-    /**
119
-     * Retrieve field label class
120
-     * @return string
121
-     */
122
-    function get_label_class() {
123
-        return 'gv-label-'. sanitize_html_class( $this->field['type'] );
124
-    }
125
-
126
-
127
-    /**
128
-     * Retrieve field description
129
-     * @return string
130
-     */
131
-    function get_field_desc() {
132
-        return !empty( $this->field['desc'] ) ? '<span class="howto">'. $this->field['desc'] .'</span>' : '';
133
-    }
134
-
135
-
136
-    /**
137
-     * Verify if field should have merge tags
138
-     * @return boolean
139
-     */
140
-    function show_merge_tags() {
141
-        // Show the merge tags if the field is a list view
142
-        $is_list = preg_match( '/_list-/ism', $this->name );
143
-        // Or is a single entry view
144
-        $is_single = preg_match( '/single_/ism', $this->name );
145
-
146
-        return ( $is_single || $is_list );
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * important! Override this class
153
-     * outputs the field option html
154
-     */
155
-    function render_option() {
156
-        // to replace on each field
157
-    }
158
-
159
-    /**
160
-     * important! Override this class if needed
161
-     * outputs the field setting html
162
-     */
163
-    function render_setting( $override_input = NULL ) {
164
-
165
-        if( !empty( $this->field['full_width'] ) ) { ?>
118
+	/**
119
+	 * Retrieve field label class
120
+	 * @return string
121
+	 */
122
+	function get_label_class() {
123
+		return 'gv-label-'. sanitize_html_class( $this->field['type'] );
124
+	}
125
+
126
+
127
+	/**
128
+	 * Retrieve field description
129
+	 * @return string
130
+	 */
131
+	function get_field_desc() {
132
+		return !empty( $this->field['desc'] ) ? '<span class="howto">'. $this->field['desc'] .'</span>' : '';
133
+	}
134
+
135
+
136
+	/**
137
+	 * Verify if field should have merge tags
138
+	 * @return boolean
139
+	 */
140
+	function show_merge_tags() {
141
+		// Show the merge tags if the field is a list view
142
+		$is_list = preg_match( '/_list-/ism', $this->name );
143
+		// Or is a single entry view
144
+		$is_single = preg_match( '/single_/ism', $this->name );
145
+
146
+		return ( $is_single || $is_list );
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * important! Override this class
153
+	 * outputs the field option html
154
+	 */
155
+	function render_option() {
156
+		// to replace on each field
157
+	}
158
+
159
+	/**
160
+	 * important! Override this class if needed
161
+	 * outputs the field setting html
162
+	 */
163
+	function render_setting( $override_input = NULL ) {
164
+
165
+		if( !empty( $this->field['full_width'] ) ) { ?>
166 166
             <th scope="row" colspan="2">
167 167
                 <div>
168 168
                     <label for="<?php echo $this->get_field_id(); ?>">
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
             </td>
183 183
         <?php }
184 184
 
185
-    }
185
+	}
186 186
 
187
-    /**
188
-     * important! Override this class
189
-     * outputs the input html part
190
-     */
191
-    function render_input( $override_input ) {
192
-        echo '';
193
-    }
187
+	/**
188
+	 * important! Override this class
189
+	 * outputs the input html part
190
+	 */
191
+	function render_input( $override_input ) {
192
+		echo '';
193
+	}
194 194
 
195 195
 }
Please login to merge, or discard this patch.
includes/class-api.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -146,20 +146,20 @@  discard block
 block discarded – undo
146 146
 
147 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
-                // We want the merge tag to be formatted as a class. The merge tag may be
154
-                // replaced by a multiple-word value that should be output as a single class.
155
-                // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
156
-                add_filter('gform_merge_tag_filter', 'sanitize_html_class');
153
+				// We want the merge tag to be formatted as a class. The merge tag may be
154
+				// replaced by a multiple-word value that should be output as a single class.
155
+				// "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
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
-                // And then we want life to return to normal
161
-                remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
162
-            }
160
+				// And then we want life to return to normal
161
+				remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
162
+			}
163 163
 
164 164
 			// And now we want the spaces to be handled nicely.
165 165
 			$classes[] = gravityview_sanitize_html_class( $custom_class );
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			'format' => $format,
293 293
 			'entry' => $entry,
294 294
 			'field_type' => $field_type, /** {@since 1.6} */
295
-		    'field_path' => $field_path, /** {@since 1.16} */
295
+			'field_path' => $field_path, /** {@since 1.16} */
296 296
 		));
297 297
 
298 298
 		if( ! empty( $field_path ) ) {
@@ -603,29 +603,29 @@  discard block
 block discarded – undo
603 603
 		return sanitize_title( $slug );
604 604
 	}
605 605
 
606
-    /**
607
-     * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta
608
-     *
609
-     * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
610
-     *
611
-     * @param $entry array Gravity Forms entry object
612
-     * @param $form array Gravity Forms form object
613
-     */
614
-    public static function entry_create_custom_slug( $entry, $form ) {
615
-        /**
616
-         * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta
617
-         * @param boolean $custom Should we process the custom entry slug?
618
-         */
619
-        $custom = apply_filters( 'gravityview_custom_entry_slug', false );
620
-        if( $custom ) {
621
-            // create the gravityview_unique_id and save it
606
+	/**
607
+	 * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta
608
+	 *
609
+	 * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
610
+	 *
611
+	 * @param $entry array Gravity Forms entry object
612
+	 * @param $form array Gravity Forms form object
613
+	 */
614
+	public static function entry_create_custom_slug( $entry, $form ) {
615
+		/**
616
+		 * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta
617
+		 * @param boolean $custom Should we process the custom entry slug?
618
+		 */
619
+		$custom = apply_filters( 'gravityview_custom_entry_slug', false );
620
+		if( $custom ) {
621
+			// create the gravityview_unique_id and save it
622 622
 
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 );
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 );
626 626
 
627
-        }
628
-    }
627
+		}
628
+	}
629 629
 
630 630
 
631 631
 
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 
890 890
 			// If there was an error, continue to the next term.
891 891
 			if ( is_wp_error( $term_link ) ) {
892
-			    continue;
892
+				continue;
893 893
 			}
894 894
 
895 895
 			$output[] = gravityview_get_link( $term_link, esc_html( $term->name ) );
Please login to merge, or discard this patch.
includes/widgets/search-widget/class-search-widget.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -386,14 +386,14 @@
 block discarded – undo
386 386
 		$curr_start = esc_attr( rgget( 'gv_start' ) );
387 387
 		$curr_end = esc_attr( rgget( 'gv_end' ) );
388 388
 
389
-        /**
390
-         * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n
391
-         * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php)
392
-         * @since 1.12
393
-         * @param[out,in] boolean $adjust_tz  Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true
394
-         * @param[in] string $context Where the filter is being called from. `search` in this case.
395
-         */
396
-        $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' );
389
+		/**
390
+		 * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n
391
+		 * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php)
392
+		 * @since 1.12
393
+		 * @param[out,in] boolean $adjust_tz  Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true
394
+		 * @param[in] string $context Where the filter is being called from. `search` in this case.
395
+		 */
396
+		$adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' );
397 397
 
398 398
 
399 399
 		/**
Please login to merge, or discard this patch.
includes/class-gravityview-settings.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
                     type="' . $field['type'] . '"
419 419
                     name="' . esc_attr( $name ) . '"
420 420
                     value="' . $value . '" ' .
421
-		        implode( ' ', $attributes ) .
422
-		        ' />';
421
+				implode( ' ', $attributes ) .
422
+				' />';
423 423
 
424 424
 		if ( $echo ) {
425 425
 			echo $html;
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 					array(
649 649
 						'label' => _x( 'Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview' ),
650 650
 						'value' => 'delete',
651
-					    'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ),
651
+						'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ),
652 652
 					),
653 653
 				),
654 654
 				'description'   => sprintf( __( 'Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview' ), __( 'Permanently Delete', 'gravityview' ) ),
@@ -674,36 +674,36 @@  discard block
 block discarded – undo
674 674
 		}
675 675
 
676 676
 
677
-        $sections = array(
678
-            array(
679
-                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
680
-                'fields'      => $fields,
681
-            )
682
-        );
677
+		$sections = array(
678
+			array(
679
+				'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
680
+				'fields'      => $fields,
681
+			)
682
+		);
683 683
 
684
-        // custom 'update settings' button
685
-        $button = array(
686
-            'class' => 'button button-primary button-hero',
687
-            'type'     => 'save',
688
-        );
684
+		// custom 'update settings' button
685
+		$button = array(
686
+			'class' => 'button button-primary button-hero',
687
+			'type'     => 'save',
688
+		);
689 689
 
690 690
 		if( $disabled_attribute ) {
691 691
 			$button['disabled'] = $disabled_attribute;
692 692
 		}
693 693
 
694 694
 
695
-        /**
696
-         * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
697
-         * Extensions can tap in here to insert their own section and settings.
698
-         * <code>
699
-         *   $sections[] = array(
700
-         *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
701
-         *      'fields' => $settings,
702
-         *   );
703
-         * </code>
704
-         * @param array $extension_settings Empty array, ready for extension settings!
705
-         */
706
-        $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() );
695
+		/**
696
+		 * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
697
+		 * Extensions can tap in here to insert their own section and settings.
698
+		 * <code>
699
+		 *   $sections[] = array(
700
+		 *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
701
+		 *      'fields' => $settings,
702
+		 *   );
703
+		 * </code>
704
+		 * @param array $extension_settings Empty array, ready for extension settings!
705
+		 */
706
+		$extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() );
707 707
 
708 708
 		// If there are extensions, add a section for them
709 709
 		if ( ! empty( $extension_sections ) ) {
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 				}
717 717
 			}
718 718
 
719
-            $k = count( $extension_sections ) - 1 ;
720
-            $extension_sections[ $k ]['fields'][] = $button;
719
+			$k = count( $extension_sections ) - 1 ;
720
+			$extension_sections[ $k ]['fields'][] = $button;
721 721
 			$sections = array_merge( $sections, $extension_sections );
722 722
 		} else {
723
-            // add the 'update settings' button to the general section
724
-            $sections[0]['fields'][] = $button;
725
-        }
723
+			// add the 'update settings' button to the general section
724
+			$sections[0]['fields'][] = $button;
725
+		}
726 726
 
727 727
 		return $sections;
728 728
 	}
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-user-registration.php 1 patch
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 if ( ! defined( 'WPINC' ) ) {
14
-    die;
14
+	die;
15 15
 }
16 16
 
17 17
 /**
@@ -22,255 +22,255 @@  discard block
 block discarded – undo
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
-         * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
97
-         * @since 1.15
98
-         * @param[in,out] boolean $preserve_role Preserve current user role Default: true
99
-         * @param[in] array $config Gravity Forms User Registration feed configuration for the form
100
-         * @param[in] array $form Gravity Forms form array
101
-         * @param[in] array $entry Gravity Forms entry being edited
102
-         */
103
-        $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
104
-
105
-        if( $preserve_role ) {
106
-            $config['meta']['role'] = 'gfur_preserve_role';
107
-        }
108
-
109
-        /**
110
-         * Make sure the current display name is not changed with the update user method.
111
-         * @since 1.15
112
-         */
113
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
114
-
115
-
116
-        /**
117
-         * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
118
-         * @since 1.14
119
-         * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
120
-         * @param[in] array $form Gravity Forms form array
121
-         * @param[in] array $entry Gravity Forms entry being edited
122
-         */
123
-        $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
124
-
125
-
126
-        $feed_pos = $gf_user_3 ? 'meta/feedType' : 'meta/feed_type';
127
-        $is_create_feed = ( $config && rgars( $config, $feed_pos ) === 'create' );
128
-
129
-        // Only update if it's a create feed
130
-        if( ! $is_create_feed ) {
131
-            return;
132
-        }
133
-
134
-        // The priority is set to 3 so that default priority (10) will still override it
135
-        add_filter( 'send_password_change_email', '__return_false', 3 );
136
-        add_filter( 'send_email_change_email', '__return_false', 3 );
137
-
138
-        // Trigger the User Registration update user method
139
-        if( $gf_user_3 ) {
140
-            $gf_user_registration->update_user( $entry, $form, $config );
141
-        } else {
142
-            GFUser::update_user( $entry, $form, $config );
143
-        }
144
-
145
-
146
-        remove_filter( 'send_password_change_email', '__return_false', 3 );
147
-        remove_filter( 'send_email_change_email', '__return_false', 3 );
148
-
149
-    }
150
-
151
-    /**
152
-     * Calculate the user display name format
153
-     *
154
-     * @since 1.15
155
-     *
156
-     * @param int $user_id WP User ID
157
-     * @return string Display name format as used inside Gravity Forms User Registration
158
-     */
159
-    public function match_current_display_name( $user_id ) {
160
-
161
-        $user = get_userdata( $user_id );
162
-
163
-        $names = $this->generate_display_names( $user );
164
-
165
-        $format = array_search( $user->display_name, $names, true );
166
-
167
-        // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
168
-        //   trigger last resort method at the 'gform_user_updated' hook
169
-        if( false === $format || 'nickname' === $format ) {
170
-            $this->_user_before_update = $user;
171
-            $format = 'nickname';
172
-        }
173
-
174
-        return $format;
175
-
176
-    }
177
-
178
-    /**
179
-     * Generate an array of all the user display names possibilities
180
-     *
181
-     * @since 1.15
182
-     *
183
-     * @param object $profileuser WP_User object
184
-     * @return array List all the possible display names for a certain User object
185
-     */
186
-    public function generate_display_names( $profileuser ) {
187
-
188
-        $public_display = array();
189
-        $public_display['nickname']  = $profileuser->nickname;
190
-        $public_display['username']  = $profileuser->user_login;
191
-
192
-        if ( !empty($profileuser->first_name) )
193
-            $public_display['firstname'] = $profileuser->first_name;
194
-
195
-        if ( !empty($profileuser->last_name) )
196
-            $public_display['lastname'] = $profileuser->last_name;
197
-
198
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
199
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
200
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
201
-        }
202
-
203
-        $public_display = array_map( 'trim', $public_display );
204
-        $public_display = array_unique( $public_display );
205
-
206
-        return $public_display;
207
-    }
208
-
209
-
210
-    /**
211
-     * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
212
-     *
213
-     * @see GFUser::update_user()
214
-     * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
215
-     * @param array $config Gravity Forms User Registration Addon form feed configuration
216
-     * @param array $entry The Gravity Forms entry that was just updated
217
-     * @param string $password User password
218
-     * @return void
219
-     */
220
-    public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
221
-
222
-        /**
223
-         * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
224
-         * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
225
-         * @since 1.14.4
226
-         * @param boolean $restore_display_name Restore Display Name? Default: true
227
-         */
228
-        $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
229
-
230
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
231
-
232
-        /**
233
-         * Don't restore display name:
234
-         *   - either disabled,
235
-         *   - or it is an Update feed (we only care about Create feed)
236
-         *   - or we don't need as we found the correct format before updating user.
237
-         * @since 1.14.4
238
-         */
239
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
240
-            return;
241
-        }
242
-
243
-        $user_after_update = get_userdata( $user_id );
244
-
245
-        $restored_user = $user_after_update;
246
-
247
-	    // Restore previous display_name
248
-        $restored_user->display_name = $this->_user_before_update->display_name;
249
-
250
-	    // Don't have WP update the password.
251
-	    unset( $restored_user->data->user_pass, $restored_user->user_pass );
252
-
253
-        /**
254
-         * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
255
-         * @since 1.14
256
-         * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
257
-         * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
258
-         * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
259
-         * @param array   $entry The Gravity Forms entry that was just updated
260
-         */
261
-        $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
262
-
263
-        $updated = wp_update_user( $restored_user );
264
-
265
-        if( is_wp_error( $updated ) ) {
266
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
267
-        } else {
268
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
269
-        }
270
-
271
-        $this->_user_before_update = null;
272
-
273
-        unset( $updated, $restored_user, $user_after_update );
274
-    }
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
+		 * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
97
+		 * @since 1.15
98
+		 * @param[in,out] boolean $preserve_role Preserve current user role Default: true
99
+		 * @param[in] array $config Gravity Forms User Registration feed configuration for the form
100
+		 * @param[in] array $form Gravity Forms form array
101
+		 * @param[in] array $entry Gravity Forms entry being edited
102
+		 */
103
+		$preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
104
+
105
+		if( $preserve_role ) {
106
+			$config['meta']['role'] = 'gfur_preserve_role';
107
+		}
108
+
109
+		/**
110
+		 * Make sure the current display name is not changed with the update user method.
111
+		 * @since 1.15
112
+		 */
113
+		$config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
114
+
115
+
116
+		/**
117
+		 * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
118
+		 * @since 1.14
119
+		 * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
120
+		 * @param[in] array $form Gravity Forms form array
121
+		 * @param[in] array $entry Gravity Forms entry being edited
122
+		 */
123
+		$config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
124
+
125
+
126
+		$feed_pos = $gf_user_3 ? 'meta/feedType' : 'meta/feed_type';
127
+		$is_create_feed = ( $config && rgars( $config, $feed_pos ) === 'create' );
128
+
129
+		// Only update if it's a create feed
130
+		if( ! $is_create_feed ) {
131
+			return;
132
+		}
133
+
134
+		// The priority is set to 3 so that default priority (10) will still override it
135
+		add_filter( 'send_password_change_email', '__return_false', 3 );
136
+		add_filter( 'send_email_change_email', '__return_false', 3 );
137
+
138
+		// Trigger the User Registration update user method
139
+		if( $gf_user_3 ) {
140
+			$gf_user_registration->update_user( $entry, $form, $config );
141
+		} else {
142
+			GFUser::update_user( $entry, $form, $config );
143
+		}
144
+
145
+
146
+		remove_filter( 'send_password_change_email', '__return_false', 3 );
147
+		remove_filter( 'send_email_change_email', '__return_false', 3 );
148
+
149
+	}
150
+
151
+	/**
152
+	 * Calculate the user display name format
153
+	 *
154
+	 * @since 1.15
155
+	 *
156
+	 * @param int $user_id WP User ID
157
+	 * @return string Display name format as used inside Gravity Forms User Registration
158
+	 */
159
+	public function match_current_display_name( $user_id ) {
160
+
161
+		$user = get_userdata( $user_id );
162
+
163
+		$names = $this->generate_display_names( $user );
164
+
165
+		$format = array_search( $user->display_name, $names, true );
166
+
167
+		// In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
168
+		//   trigger last resort method at the 'gform_user_updated' hook
169
+		if( false === $format || 'nickname' === $format ) {
170
+			$this->_user_before_update = $user;
171
+			$format = 'nickname';
172
+		}
173
+
174
+		return $format;
175
+
176
+	}
177
+
178
+	/**
179
+	 * Generate an array of all the user display names possibilities
180
+	 *
181
+	 * @since 1.15
182
+	 *
183
+	 * @param object $profileuser WP_User object
184
+	 * @return array List all the possible display names for a certain User object
185
+	 */
186
+	public function generate_display_names( $profileuser ) {
187
+
188
+		$public_display = array();
189
+		$public_display['nickname']  = $profileuser->nickname;
190
+		$public_display['username']  = $profileuser->user_login;
191
+
192
+		if ( !empty($profileuser->first_name) )
193
+			$public_display['firstname'] = $profileuser->first_name;
194
+
195
+		if ( !empty($profileuser->last_name) )
196
+			$public_display['lastname'] = $profileuser->last_name;
197
+
198
+		if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
199
+			$public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
200
+			$public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
201
+		}
202
+
203
+		$public_display = array_map( 'trim', $public_display );
204
+		$public_display = array_unique( $public_display );
205
+
206
+		return $public_display;
207
+	}
208
+
209
+
210
+	/**
211
+	 * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
212
+	 *
213
+	 * @see GFUser::update_user()
214
+	 * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
215
+	 * @param array $config Gravity Forms User Registration Addon form feed configuration
216
+	 * @param array $entry The Gravity Forms entry that was just updated
217
+	 * @param string $password User password
218
+	 * @return void
219
+	 */
220
+	public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
221
+
222
+		/**
223
+		 * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
224
+		 * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
225
+		 * @since 1.14.4
226
+		 * @param boolean $restore_display_name Restore Display Name? Default: true
227
+		 */
228
+		$restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
229
+
230
+		$is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
231
+
232
+		/**
233
+		 * Don't restore display name:
234
+		 *   - either disabled,
235
+		 *   - or it is an Update feed (we only care about Create feed)
236
+		 *   - or we don't need as we found the correct format before updating user.
237
+		 * @since 1.14.4
238
+		 */
239
+		if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
240
+			return;
241
+		}
242
+
243
+		$user_after_update = get_userdata( $user_id );
244
+
245
+		$restored_user = $user_after_update;
246
+
247
+		// Restore previous display_name
248
+		$restored_user->display_name = $this->_user_before_update->display_name;
249
+
250
+		// Don't have WP update the password.
251
+		unset( $restored_user->data->user_pass, $restored_user->user_pass );
252
+
253
+		/**
254
+		 * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
255
+		 * @since 1.14
256
+		 * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
257
+		 * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
258
+		 * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
259
+		 * @param array   $entry The Gravity Forms entry that was just updated
260
+		 */
261
+		$restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
262
+
263
+		$updated = wp_update_user( $restored_user );
264
+
265
+		if( is_wp_error( $updated ) ) {
266
+			do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
267
+		} else {
268
+			do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
269
+		}
270
+
271
+		$this->_user_before_update = null;
272
+
273
+		unset( $updated, $restored_user, $user_after_update );
274
+	}
275 275
 
276 276
 } //end class
Please login to merge, or discard this patch.