Completed
Push — master ( 21157a...9cf7be )
by Zack
84:58 queued 65:12
created
includes/extensions/edit-entry/class-edit-entry-admin.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -10,175 +10,175 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 if ( ! defined( 'WPINC' ) ) {
13
-    die;
13
+	die;
14 14
 }
15 15
 
16 16
 
17 17
 class GravityView_Edit_Entry_Admin {
18 18
 
19
-    protected $loader;
19
+	protected $loader;
20 20
 
21
-    function __construct( GravityView_Edit_Entry $loader ) {
22
-        $this->loader = $loader;
23
-    }
21
+	function __construct( GravityView_Edit_Entry $loader ) {
22
+		$this->loader = $loader;
23
+	}
24 24
 
25
-    function load() {
26
-
27
-        if( !is_admin() ) {
28
-            return;
29
-        }
30
-
31
-        // Add Edit Link as a default field, outside those set in the Gravity Form form
32
-        add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
-
34
-        // For the Edit Entry Link, you don't want visible to all users.
35
-        add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
25
+	function load() {
26
+
27
+		if( !is_admin() ) {
28
+			return;
29
+		}
30
+
31
+		// Add Edit Link as a default field, outside those set in the Gravity Form form
32
+		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
+
34
+		// For the Edit Entry Link, you don't want visible to all users.
35
+		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
36 36
 
37
-        // Modify the field options based on the name of the field type
38
-        add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
37
+		// Modify the field options based on the name of the field type
38
+		add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40
-        // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
-
43
-        // custom fields' options for zone EDIT
44
-        add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
-    }
46
-
47
-    /**
48
-     * Add Edit Link as a default field, outside those set in the Gravity Form form
49
-     * @param array $entry_default_fields Existing fields
50
-     * @param  string|array $form form_ID or form object
51
-     * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
-     */
53
-    function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
-
55
-        if( $zone !== 'edit' ) {
56
-
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
59
-                'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
-            );
62
-
63
-        }
64
-
65
-        return $entry_default_fields;
66
-    }
67
-
68
-    /**
69
-     * Change wording for the Edit context to read Entry Creator
70
-     *
71
-     * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
-     * @param  string      $template_id Table slug
74
-     * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
-     * @param  string      $context     What context are we in? Example: `single` or `directory`
76
-     * @param  string      $input_type  (textarea, list, select, etc.)
77
-     * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
-     */
79
-    function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
-
81
-        $caps = $visibility_caps;
82
-
83
-        // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
85
-
86
-            // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
-
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
-        }
91
-
92
-        return $caps;
93
-    }
94
-
95
-    /**
96
-     * Add "Edit Link Text" setting to the edit_link field settings
97
-     * @param  [type] $field_options [description]
98
-     * @param  [type] $template_id   [description]
99
-     * @param  [type] $field_id      [description]
100
-     * @param  [type] $context       [description]
101
-     * @param  [type] $input_type    [description]
102
-     * @return [type]                [description]
103
-     */
104
-    function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
-
106
-        // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
-
109
-        // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
-
112
-        $add_option['edit_link'] = array(
113
-            'type' => 'text',
114
-            'label' => __( 'Edit Link Text', 'gravityview' ),
115
-            'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
117
-            'merge_tags' => true,
118
-        );
119
-
120
-        return array_merge( $add_option, $field_options );
121
-    }
122
-
123
-    /**
124
-     * Add tooltips
125
-     * @param  array $tooltips Existing tooltips
126
-     * @return array           Modified tooltips
127
-     */
128
-    function tooltips( $tooltips ) {
129
-
130
-        $return = $tooltips;
131
-
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
-        );
136
-
137
-        return $return;
138
-    }
139
-
140
-    /**
141
-     * Manipulate the fields' options for the EDIT ENTRY screen
142
-     * @param  [type] $field_options [description]
143
-     * @param  [type] $template_id   [description]
144
-     * @param  [type] $field_id      [description]
145
-     * @param  [type] $context       [description]
146
-     * @param  [type] $input_type    [description]
147
-     * @return [type]                [description]
148
-     */
149
-    function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
-
151
-        // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
153
-
154
-            /**
155
-             * @since 1.8.4
156
-             */
157
-            $field_options['new_window'] = array(
158
-                'type' => 'checkbox',
159
-                'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
-                'value' => false,
161
-            );
162
-
163
-            return $field_options;
164
-        }
165
-
166
-        //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
-
169
-        $add_options = array(
170
-            'allow_edit_cap' => array(
171
-                'type' => 'select',
172
-                'label' => __( 'Make field editable to:', 'gravityview' ),
173
-                'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
-                'tooltip' => 'allow_edit_cap',
175
-                'class' => 'widefat',
176
-                'value' => 'read', // Default: entry creator
177
-            ),
178
-        );
179
-
180
-        return array_merge( $field_options, $add_options );
181
-    }
40
+		// add tooltips
41
+		add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
+
43
+		// custom fields' options for zone EDIT
44
+		add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
+	}
46
+
47
+	/**
48
+	 * Add Edit Link as a default field, outside those set in the Gravity Form form
49
+	 * @param array $entry_default_fields Existing fields
50
+	 * @param  string|array $form form_ID or form object
51
+	 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
+	 */
53
+	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
+
55
+		if( $zone !== 'edit' ) {
56
+
57
+			$entry_default_fields['edit_link'] = array(
58
+				'label' => __('Edit Entry', 'gravityview'),
59
+				'type' => 'edit_link',
60
+				'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
+			);
62
+
63
+		}
64
+
65
+		return $entry_default_fields;
66
+	}
67
+
68
+	/**
69
+	 * Change wording for the Edit context to read Entry Creator
70
+	 *
71
+	 * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
+	 * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
+	 * @param  string      $template_id Table slug
74
+	 * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
+	 * @param  string      $context     What context are we in? Example: `single` or `directory`
76
+	 * @param  string      $input_type  (textarea, list, select, etc.)
77
+	 * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
+	 */
79
+	function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
+
81
+		$caps = $visibility_caps;
82
+
83
+		// If we're configuring fields in the edit context, we want a limited selection
84
+		if( $context === 'edit' ) {
85
+
86
+			// Remove other built-in caps.
87
+			unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
+
89
+			$caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
+		}
91
+
92
+		return $caps;
93
+	}
94
+
95
+	/**
96
+	 * Add "Edit Link Text" setting to the edit_link field settings
97
+	 * @param  [type] $field_options [description]
98
+	 * @param  [type] $template_id   [description]
99
+	 * @param  [type] $field_id      [description]
100
+	 * @param  [type] $context       [description]
101
+	 * @param  [type] $input_type    [description]
102
+	 * @return [type]                [description]
103
+	 */
104
+	function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
+
106
+		// Always a link, never a filter
107
+		unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
+
109
+		// Edit Entry link should only appear to visitors capable of editing entries
110
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
+
112
+		$add_option['edit_link'] = array(
113
+			'type' => 'text',
114
+			'label' => __( 'Edit Link Text', 'gravityview' ),
115
+			'desc' => NULL,
116
+			'value' => __('Edit Entry', 'gravityview'),
117
+			'merge_tags' => true,
118
+		);
119
+
120
+		return array_merge( $add_option, $field_options );
121
+	}
122
+
123
+	/**
124
+	 * Add tooltips
125
+	 * @param  array $tooltips Existing tooltips
126
+	 * @return array           Modified tooltips
127
+	 */
128
+	function tooltips( $tooltips ) {
129
+
130
+		$return = $tooltips;
131
+
132
+		$return['allow_edit_cap'] = array(
133
+			'title' => __('Limiting Edit Access', 'gravityview'),
134
+			'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
+		);
136
+
137
+		return $return;
138
+	}
139
+
140
+	/**
141
+	 * Manipulate the fields' options for the EDIT ENTRY screen
142
+	 * @param  [type] $field_options [description]
143
+	 * @param  [type] $template_id   [description]
144
+	 * @param  [type] $field_id      [description]
145
+	 * @param  [type] $context       [description]
146
+	 * @param  [type] $input_type    [description]
147
+	 * @return [type]                [description]
148
+	 */
149
+	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
+
151
+		// We only want to modify the settings for the edit context
152
+		if( 'edit' !== $context ) {
153
+
154
+			/**
155
+			 * @since 1.8.4
156
+			 */
157
+			$field_options['new_window'] = array(
158
+				'type' => 'checkbox',
159
+				'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
+				'value' => false,
161
+			);
162
+
163
+			return $field_options;
164
+		}
165
+
166
+		//  Entry field is only for logged in users
167
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
+
169
+		$add_options = array(
170
+			'allow_edit_cap' => array(
171
+				'type' => 'select',
172
+				'label' => __( 'Make field editable to:', 'gravityview' ),
173
+				'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
+				'tooltip' => 'allow_edit_cap',
175
+				'class' => 'widefat',
176
+				'value' => 'read', // Default: entry creator
177
+			),
178
+		);
179
+
180
+		return array_merge( $field_options, $add_options );
181
+	}
182 182
 
183 183
 
184 184
 } // end class
185 185
\ No newline at end of file
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-user-registration.php 1 patch
Indentation   +225 added lines, -225 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,237 +22,237 @@  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
-        $entry = GFAPI::get_entry( $entry_id );
70
-
71
-	    /**
72
-	     * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
73
-	     * @since 1.11
74
-	     * @param array $entry Gravity Forms entry
75
-	     * @param array $form Gravity Forms form
76
-	     */
77
-        $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
78
-
79
-        /**
80
-         * @since 1.14
81
-         */
82
-        $config = GFUser::get_active_config( $form, $entry );
83
-
84
-        /**
85
-         * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
86
-         * @since 1.15
87
-         * @param[in,out] boolean $preserve_role Preserve current user role Default: true
88
-         * @param[in] array $config Gravity Forms User Registration feed configuration for the form
89
-         * @param[in] array $form Gravity Forms form array
90
-         * @param[in] array $entry Gravity Forms entry being edited
91
-         */
92
-        $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
93
-
94
-        if( $preserve_role ) {
95
-            $config['meta']['role'] = 'gfur_preserve_role';
96
-        }
97
-
98
-        /**
99
-         * Make sure the current display name is not changed with the update user method.
100
-         * @since 1.15
101
-         */
102
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
103
-
104
-
105
-        /**
106
-         * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
107
-         * @since 1.14
108
-         * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
109
-         * @param[in] array $form Gravity Forms form array
110
-         * @param[in] array $entry Gravity Forms entry being edited
111
-         */
112
-        $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
113
-
114
-        $is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' );
115
-
116
-        // Only update if it's a create feed
117
-        if( ! $is_create_feed ) {
118
-            return;
119
-        }
120
-
121
-        // The priority is set to 3 so that default priority (10) will still override it
122
-        add_filter( 'send_password_change_email', '__return_false', 3 );
123
-        add_filter( 'send_email_change_email', '__return_false', 3 );
124
-
125
-        // Trigger the User Registration update user method
126
-        GFUser::update_user( $entry, $form, $config );
127
-
128
-        remove_filter( 'send_password_change_email', '__return_false', 3 );
129
-        remove_filter( 'send_email_change_email', '__return_false', 3 );
130
-
131
-    }
132
-
133
-    /**
134
-     * Calculate the user display name format
135
-     *
136
-     * @since 1.15
137
-     *
138
-     * @param int $user_id WP User ID
139
-     * @return string Display name format as used inside Gravity Forms User Registration
140
-     */
141
-    public function match_current_display_name( $user_id ) {
142
-
143
-        $user = get_userdata( $user_id );
144
-
145
-        $names = $this->generate_display_names( $user );
146
-
147
-        $format = array_search( $user->display_name, $names, true );
148
-
149
-        // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
150
-        //   trigger last resort method at the 'gform_user_updated' hook
151
-        if( false === $format || 'nickname' === $format ) {
152
-            $this->_user_before_update = $user;
153
-            $format = 'nickname';
154
-        }
155
-
156
-        return $format;
157
-
158
-    }
159
-
160
-    /**
161
-     * Generate an array of all the user display names possibilities
162
-     *
163
-     * @since 1.15
164
-     *
165
-     * @param object $profileuser WP_User object
166
-     * @return array List all the possible display names for a certain User object
167
-     */
168
-    public function generate_display_names( $profileuser ) {
169
-
170
-        $public_display = array();
171
-        $public_display['nickname']  = $profileuser->nickname;
172
-        $public_display['username']  = $profileuser->user_login;
173
-
174
-        if ( !empty($profileuser->first_name) )
175
-            $public_display['firstname'] = $profileuser->first_name;
176
-
177
-        if ( !empty($profileuser->last_name) )
178
-            $public_display['lastname'] = $profileuser->last_name;
179
-
180
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
181
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
182
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
183
-        }
184
-
185
-        $public_display = array_map( 'trim', $public_display );
186
-        $public_display = array_unique( $public_display );
187
-
188
-        return $public_display;
189
-    }
190
-
191
-
192
-    /**
193
-     * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
194
-     *
195
-     * @see GFUser::update_user()
196
-     * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
197
-     * @param array $config Gravity Forms User Registration Addon form feed configuration
198
-     * @param array $entry The Gravity Forms entry that was just updated
199
-     * @param string $password User password
200
-     * @return void
201
-     */
202
-    public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
203
-
204
-        /**
205
-         * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
206
-         * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
207
-         * @since 1.14.4
208
-         * @param boolean $restore_display_name Restore Display Name? Default: true
209
-         */
210
-        $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
211
-
212
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
213
-
214
-        /**
215
-         * Don't restore display name:
216
-         *   - either disabled,
217
-         *   - or it is an Update feed (we only care about Create feed)
218
-         *   - or we don't need as we found the correct format before updating user.
219
-         * @since 1.14.4
220
-         */
221
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
222
-            return;
223
-        }
224
-
225
-        $user_after_update = get_userdata( $user_id );
226
-
227
-        $restored_user = $user_after_update;
228
-
229
-	    // Restore previous display_name
230
-        $restored_user->display_name = $this->_user_before_update->display_name;
231
-
232
-	    // Don't have WP update the password.
233
-	    unset( $restored_user->data->user_pass, $restored_user->user_pass );
234
-
235
-        /**
236
-         * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
237
-         * @since 1.14
238
-         * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
239
-         * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
240
-         * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
241
-         * @param array   $entry The Gravity Forms entry that was just updated
242
-         */
243
-        $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
244
-
245
-        $updated = wp_update_user( $restored_user );
246
-
247
-        if( is_wp_error( $updated ) ) {
248
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
249
-        } else {
250
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
251
-        }
252
-
253
-        $this->_user_before_update = null;
254
-
255
-        unset( $updated, $restored_user, $user_after_update );
256
-    }
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
+		$entry = GFAPI::get_entry( $entry_id );
70
+
71
+		/**
72
+		 * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
73
+		 * @since 1.11
74
+		 * @param array $entry Gravity Forms entry
75
+		 * @param array $form Gravity Forms form
76
+		 */
77
+		$entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
78
+
79
+		/**
80
+		 * @since 1.14
81
+		 */
82
+		$config = GFUser::get_active_config( $form, $entry );
83
+
84
+		/**
85
+		 * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
86
+		 * @since 1.15
87
+		 * @param[in,out] boolean $preserve_role Preserve current user role Default: true
88
+		 * @param[in] array $config Gravity Forms User Registration feed configuration for the form
89
+		 * @param[in] array $form Gravity Forms form array
90
+		 * @param[in] array $entry Gravity Forms entry being edited
91
+		 */
92
+		$preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
93
+
94
+		if( $preserve_role ) {
95
+			$config['meta']['role'] = 'gfur_preserve_role';
96
+		}
97
+
98
+		/**
99
+		 * Make sure the current display name is not changed with the update user method.
100
+		 * @since 1.15
101
+		 */
102
+		$config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
103
+
104
+
105
+		/**
106
+		 * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
107
+		 * @since 1.14
108
+		 * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
109
+		 * @param[in] array $form Gravity Forms form array
110
+		 * @param[in] array $entry Gravity Forms entry being edited
111
+		 */
112
+		$config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
113
+
114
+		$is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' );
115
+
116
+		// Only update if it's a create feed
117
+		if( ! $is_create_feed ) {
118
+			return;
119
+		}
120
+
121
+		// The priority is set to 3 so that default priority (10) will still override it
122
+		add_filter( 'send_password_change_email', '__return_false', 3 );
123
+		add_filter( 'send_email_change_email', '__return_false', 3 );
124
+
125
+		// Trigger the User Registration update user method
126
+		GFUser::update_user( $entry, $form, $config );
127
+
128
+		remove_filter( 'send_password_change_email', '__return_false', 3 );
129
+		remove_filter( 'send_email_change_email', '__return_false', 3 );
130
+
131
+	}
132
+
133
+	/**
134
+	 * Calculate the user display name format
135
+	 *
136
+	 * @since 1.15
137
+	 *
138
+	 * @param int $user_id WP User ID
139
+	 * @return string Display name format as used inside Gravity Forms User Registration
140
+	 */
141
+	public function match_current_display_name( $user_id ) {
142
+
143
+		$user = get_userdata( $user_id );
144
+
145
+		$names = $this->generate_display_names( $user );
146
+
147
+		$format = array_search( $user->display_name, $names, true );
148
+
149
+		// In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
150
+		//   trigger last resort method at the 'gform_user_updated' hook
151
+		if( false === $format || 'nickname' === $format ) {
152
+			$this->_user_before_update = $user;
153
+			$format = 'nickname';
154
+		}
155
+
156
+		return $format;
157
+
158
+	}
159
+
160
+	/**
161
+	 * Generate an array of all the user display names possibilities
162
+	 *
163
+	 * @since 1.15
164
+	 *
165
+	 * @param object $profileuser WP_User object
166
+	 * @return array List all the possible display names for a certain User object
167
+	 */
168
+	public function generate_display_names( $profileuser ) {
169
+
170
+		$public_display = array();
171
+		$public_display['nickname']  = $profileuser->nickname;
172
+		$public_display['username']  = $profileuser->user_login;
173
+
174
+		if ( !empty($profileuser->first_name) )
175
+			$public_display['firstname'] = $profileuser->first_name;
176
+
177
+		if ( !empty($profileuser->last_name) )
178
+			$public_display['lastname'] = $profileuser->last_name;
179
+
180
+		if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
181
+			$public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
182
+			$public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
183
+		}
184
+
185
+		$public_display = array_map( 'trim', $public_display );
186
+		$public_display = array_unique( $public_display );
187
+
188
+		return $public_display;
189
+	}
190
+
191
+
192
+	/**
193
+	 * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
194
+	 *
195
+	 * @see GFUser::update_user()
196
+	 * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
197
+	 * @param array $config Gravity Forms User Registration Addon form feed configuration
198
+	 * @param array $entry The Gravity Forms entry that was just updated
199
+	 * @param string $password User password
200
+	 * @return void
201
+	 */
202
+	public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
203
+
204
+		/**
205
+		 * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
206
+		 * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
207
+		 * @since 1.14.4
208
+		 * @param boolean $restore_display_name Restore Display Name? Default: true
209
+		 */
210
+		$restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
211
+
212
+		$is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
213
+
214
+		/**
215
+		 * Don't restore display name:
216
+		 *   - either disabled,
217
+		 *   - or it is an Update feed (we only care about Create feed)
218
+		 *   - or we don't need as we found the correct format before updating user.
219
+		 * @since 1.14.4
220
+		 */
221
+		if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
222
+			return;
223
+		}
224
+
225
+		$user_after_update = get_userdata( $user_id );
226
+
227
+		$restored_user = $user_after_update;
228
+
229
+		// Restore previous display_name
230
+		$restored_user->display_name = $this->_user_before_update->display_name;
231
+
232
+		// Don't have WP update the password.
233
+		unset( $restored_user->data->user_pass, $restored_user->user_pass );
234
+
235
+		/**
236
+		 * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
237
+		 * @since 1.14
238
+		 * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
239
+		 * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
240
+		 * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
241
+		 * @param array   $entry The Gravity Forms entry that was just updated
242
+		 */
243
+		$restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
244
+
245
+		$updated = wp_update_user( $restored_user );
246
+
247
+		if( is_wp_error( $updated ) ) {
248
+			do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
249
+		} else {
250
+			do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
251
+		}
252
+
253
+		$this->_user_before_update = null;
254
+
255
+		unset( $updated, $restored_user, $user_after_update );
256
+	}
257 257
 
258 258
 } //end class
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 1 patch
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -18,82 +18,82 @@  discard block
 block discarded – undo
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' ) ) {
48
-            $this->load_components( 'user-registration' );
49
-        }
46
+		// If GF User Registration Add-on exists
47
+		if( class_exists( 'GFUser' ) ) {
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
includes/extensions/edit-entry/partials/form-buttons.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
 <div id="publishing-action">
8 8
 	<?php
9 9
 
10
-    /**
11
-     * @filter `gravityview/edit_entry/cancel_link` Modify the cancel button link URL
12
-     * @since 1.11.1
13
-     * @param string $back_link Existing URL of the Cancel link
14
-     * @param array $form The Gravity Forms form
15
-     * @param array $entry The Gravity Forms entry
16
-     * @param int $view_id The current View ID
17
-     */
18
-    $back_link = apply_filters( 'gravityview/edit_entry/cancel_link', remove_query_arg( array( 'page', 'view', 'edit' ) ), $object->form, $object->entry, $object->view_id );
10
+	/**
11
+	 * @filter `gravityview/edit_entry/cancel_link` Modify the cancel button link URL
12
+	 * @since 1.11.1
13
+	 * @param string $back_link Existing URL of the Cancel link
14
+	 * @param array $form The Gravity Forms form
15
+	 * @param array $entry The Gravity Forms entry
16
+	 * @param int $view_id The current View ID
17
+	 */
18
+	$back_link = apply_filters( 'gravityview/edit_entry/cancel_link', remove_query_arg( array( 'page', 'view', 'edit' ) ), $object->form, $object->entry, $object->view_id );
19 19
 
20 20
 	/**
21 21
 	 * @action `gravityview/edit-entry/publishing-action/before` Triggered before the submit buttons in the Edit Entry screen, inside the `<div id="publishing-action">` container.
Please login to merge, or discard this patch.
includes/helper-functions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -307,7 +307,7 @@
 block discarded – undo
307 307
 		! isset( $value ) // If it's not set, it's empty!
308 308
 		|| false === $value
309 309
 		|| null === $value
310
-	    || '' === $value // Empty string
310
+		|| '' === $value // Empty string
311 311
 		|| array() === $value // Empty array
312 312
 		|| ( is_object( $value ) && ! get_object_vars( $value ) ) // Empty object
313 313
 	) {
Please login to merge, or discard this patch.
includes/widgets/class-gravityview-widget.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -116,12 +116,12 @@
 block discarded – undo
116 116
 		return $settings;
117 117
 	}
118 118
 
119
-    /**
120
-     * @return string
121
-     */
122
-    public function get_widget_id() {
123
-        return $this->widget_id;
124
-    }
119
+	/**
120
+	 * @return string
121
+	 */
122
+	public function get_widget_id() {
123
+		return $this->widget_id;
124
+	}
125 125
 
126 126
 	/**
127 127
 	 * Get the widget settings
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/search-field-link.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,22 +39,22 @@
 block discarded – undo
39 39
 
40 40
         <?php
41 41
 
42
-        $search_value = rgget( $search_field['name'] );
42
+		$search_value = rgget( $search_field['name'] );
43 43
 
44
-        foreach ( $search_field['choices'] as $k => $choice ) {
44
+		foreach ( $search_field['choices'] as $k => $choice ) {
45 45
 
46
-            if ( 0 != $k ) {
47
-                echo esc_html( $links_sep );
48
-            }
46
+			if ( 0 != $k ) {
47
+				echo esc_html( $links_sep );
48
+			}
49 49
 
50
-            $active = ( '' !== $search_value && in_array( $search_value, array( $choice['text'], $choice['value'] ) ) ) ? ' class="active"' : false;
50
+			$active = ( '' !== $search_value && in_array( $search_value, array( $choice['text'], $choice['value'] ) ) ) ? ' class="active"' : false;
51 51
 
52
-            if ( $active ) {
53
-                $link = remove_query_arg( array( 'pagenum', $search_field['name'] ), $base_url );
54
-            } else {
55
-                $link = add_query_arg( array( $search_field['name'] => urlencode( $choice['value'] ) ), remove_query_arg( array('pagenum'), $base_url ) );
56
-            }
57
-            ?>
52
+			if ( $active ) {
53
+				$link = remove_query_arg( array( 'pagenum', $search_field['name'] ), $base_url );
54
+			} else {
55
+				$link = add_query_arg( array( $search_field['name'] => urlencode( $choice['value'] ) ), remove_query_arg( array('pagenum'), $base_url ) );
56
+			}
57
+			?>
58 58
 
59 59
 			<a href="<?php echo esc_url_raw( $link ); ?>" <?php echo $active; ?>><?php echo esc_html( $choice['text'] ); ?></a>
60 60
 
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/search-field-radio.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Display the search RADIO input field
4
- *
5
- * @see class-search-widget.php
6
- */
3
+			 * Display the search RADIO input field
4
+			 *
5
+			 * @see class-search-widget.php
6
+			 */
7 7
 
8 8
 $gravityview_view = GravityView_View::getInstance();
9 9
 $view_id = $gravityview_view->getViewId();
Please login to merge, or discard this patch.
includes/admin/field-types/type_number.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
28 28
 
29 29
 		$show_mt = $this->show_merge_tags();
30 30
 
31
-        if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
32
-            $class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
33
-        }
34
-        $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
31
+		if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
32
+			$class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
33
+		}
34
+		$class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
35 35
 
36 36
 		?>
37 37
 		<input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="text" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>">
Please login to merge, or discard this patch.