@@ -57,7 +57,7 @@ |
||
57 | 57 | * @since 1.11 |
58 | 58 | * |
59 | 59 | * @param array $form Gravity Forms form array |
60 | - * @param string $entry_id Gravity Forms entry ID |
|
60 | + * @param integer $entry_id Gravity Forms entry ID |
|
61 | 61 | * @return void |
62 | 62 | */ |
63 | 63 | public function update_user( $form = array(), $entry_id = 0 ) { |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | if ( ! defined( 'WPINC' ) ) { |
14 | - die; |
|
14 | + die; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -22,104 +22,104 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @var GravityView_Edit_Entry |
24 | 24 | */ |
25 | - protected $loader; |
|
25 | + protected $loader; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var WP_User|null Temporary storage used by restore_user_details() |
|
29 | - */ |
|
30 | - private $_user_before_update = null; |
|
27 | + /** |
|
28 | + * @var WP_User|null Temporary storage used by restore_user_details() |
|
29 | + */ |
|
30 | + private $_user_before_update = null; |
|
31 | 31 | |
32 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
33 | - $this->loader = $loader; |
|
34 | - } |
|
32 | + function __construct( GravityView_Edit_Entry $loader ) { |
|
33 | + $this->loader = $loader; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @since 1.11 |
38 | 38 | */ |
39 | 39 | public function load() { |
40 | 40 | add_action( 'wp', array( $this, 'add_hooks' ), 10 ); |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Add hooks to trigger updating the user |
45 | 45 | * |
46 | 46 | * @since 1.18 |
47 | 47 | */ |
48 | - public function add_hooks() { |
|
49 | - |
|
50 | - /** |
|
51 | - * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
52 | - * @since 1.11 |
|
53 | - * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
54 | - */ |
|
55 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | - |
|
57 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
58 | - |
|
59 | - // last resort in case the current user display name don't match any of the defaults |
|
60 | - add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Update the WordPress user profile based on the GF User Registration create feed |
|
66 | - * |
|
67 | - * @since 1.11 |
|
68 | - * |
|
69 | - * @param array $form Gravity Forms form array |
|
70 | - * @param string $entry_id Gravity Forms entry ID |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - public function update_user( $form = array(), $entry_id = 0 ) { |
|
74 | - |
|
75 | - if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
76 | - do_action( 'gravityview_log_error', __METHOD__ . ': GFAPI or User Registration class not found; not updating the user' ); |
|
77 | - return; |
|
78 | - } elseif( empty( $entry_id ) ) { |
|
79 | - do_action( 'gravityview_log_error', __METHOD__ . ': Entry ID is empty; not updating the user', $entry_id ); |
|
80 | - return; |
|
81 | - } |
|
82 | - |
|
83 | - /** @var GF_User_Registration $gf_user_registration */ |
|
84 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
85 | - |
|
86 | - $entry = GFAPI::get_entry( $entry_id ); |
|
87 | - |
|
88 | - /** |
|
89 | - * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
90 | - * @since 1.11 |
|
91 | - * @param array $entry Gravity Forms entry |
|
92 | - * @param array $form Gravity Forms form |
|
93 | - */ |
|
94 | - $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
95 | - |
|
96 | - $config = $this->get_feed_configuration( $entry, $form ); |
|
97 | - |
|
98 | - // Make sure the feed is active |
|
99 | - if ( ! rgar( $config, 'is_active', false ) ) { |
|
48 | + public function add_hooks() { |
|
49 | + |
|
50 | + /** |
|
51 | + * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
52 | + * @since 1.11 |
|
53 | + * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
54 | + */ |
|
55 | + if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | + |
|
57 | + add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
58 | + |
|
59 | + // last resort in case the current user display name don't match any of the defaults |
|
60 | + add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Update the WordPress user profile based on the GF User Registration create feed |
|
66 | + * |
|
67 | + * @since 1.11 |
|
68 | + * |
|
69 | + * @param array $form Gravity Forms form array |
|
70 | + * @param string $entry_id Gravity Forms entry ID |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + public function update_user( $form = array(), $entry_id = 0 ) { |
|
74 | + |
|
75 | + if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
76 | + do_action( 'gravityview_log_error', __METHOD__ . ': GFAPI or User Registration class not found; not updating the user' ); |
|
100 | 77 | return; |
101 | - } |
|
78 | + } elseif( empty( $entry_id ) ) { |
|
79 | + do_action( 'gravityview_log_error', __METHOD__ . ': Entry ID is empty; not updating the user', $entry_id ); |
|
80 | + return; |
|
81 | + } |
|
82 | + |
|
83 | + /** @var GF_User_Registration $gf_user_registration */ |
|
84 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
85 | + |
|
86 | + $entry = GFAPI::get_entry( $entry_id ); |
|
102 | 87 | |
103 | - // If an Update feed, make sure the conditions are met. |
|
104 | - if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
105 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
106 | - return; |
|
107 | - } |
|
108 | - } |
|
88 | + /** |
|
89 | + * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
90 | + * @since 1.11 |
|
91 | + * @param array $entry Gravity Forms entry |
|
92 | + * @param array $form Gravity Forms form |
|
93 | + */ |
|
94 | + $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
95 | + |
|
96 | + $config = $this->get_feed_configuration( $entry, $form ); |
|
97 | + |
|
98 | + // Make sure the feed is active |
|
99 | + if ( ! rgar( $config, 'is_active', false ) ) { |
|
100 | + return; |
|
101 | + } |
|
109 | 102 | |
110 | - // The priority is set to 3 so that default priority (10) will still override it |
|
111 | - add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
112 | - add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
103 | + // If an Update feed, make sure the conditions are met. |
|
104 | + if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
105 | + if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
106 | + return; |
|
107 | + } |
|
108 | + } |
|
113 | 109 | |
114 | - // Trigger the User Registration update user method |
|
115 | - $gf_user_registration->update_user( $entry, $form, $config ); |
|
110 | + // The priority is set to 3 so that default priority (10) will still override it |
|
111 | + add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
112 | + add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
116 | 113 | |
117 | - remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
118 | - remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
114 | + // Trigger the User Registration update user method |
|
115 | + $gf_user_registration->update_user( $entry, $form, $config ); |
|
119 | 116 | |
120 | - // Prevent double-triggering by removing the hook |
|
121 | - remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
122 | - } |
|
117 | + remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
118 | + remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
119 | + |
|
120 | + // Prevent double-triggering by removing the hook |
|
121 | + remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Get the User Registration feed configuration for the entry & form |
@@ -134,185 +134,185 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return array |
136 | 136 | */ |
137 | - public function get_feed_configuration( $entry, $form ) { |
|
138 | - |
|
139 | - /** @var GF_User_Registration $gf_user_registration */ |
|
140 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
141 | - |
|
142 | - $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
143 | - |
|
144 | - /** |
|
145 | - * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
146 | - * @since 1.15 |
|
147 | - * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
148 | - * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
149 | - * @param[in] array $form Gravity Forms form array |
|
150 | - * @param[in] array $entry Gravity Forms entry being edited |
|
151 | - */ |
|
152 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
153 | - |
|
154 | - if( $preserve_role ) { |
|
155 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
156 | - } |
|
157 | - |
|
158 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
159 | - |
|
160 | - /** |
|
161 | - * Make sure the current display name is not changed with the update user method. |
|
162 | - * @since 1.15 |
|
163 | - */ |
|
164 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
165 | - |
|
166 | - /** |
|
167 | - * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
168 | - * @since 1.14 |
|
169 | - * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
170 | - * @param[in] array $form Gravity Forms form array |
|
171 | - * @param[in] array $entry Gravity Forms entry being edited |
|
172 | - */ |
|
173 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
174 | - |
|
175 | - return $config; |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Calculate the user display name format |
|
180 | - * |
|
181 | - * @since 1.15 |
|
182 | - * @since 1.20 Returns false if user not found at $user_id |
|
183 | - * |
|
184 | - * @param int $user_id WP User ID |
|
185 | - * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
186 | - */ |
|
187 | - public function match_current_display_name( $user_id ) { |
|
188 | - |
|
189 | - $user = get_userdata( $user_id ); |
|
190 | - |
|
191 | - if( ! $user ) { |
|
192 | - return false; |
|
193 | - } |
|
194 | - |
|
195 | - $names = $this->generate_display_names( $user ); |
|
196 | - |
|
197 | - $format = array_search( $user->display_name, $names, true ); |
|
198 | - |
|
199 | - /** |
|
200 | - * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
201 | - * @see restore_display_name |
|
202 | - */ |
|
203 | - if( false === $format ) { |
|
204 | - $this->_user_before_update = $user; |
|
205 | - } |
|
206 | - |
|
207 | - return $format; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Generate an array of all the user display names possibilities |
|
212 | - * |
|
213 | - * @since 1.15 |
|
214 | - * |
|
215 | - * @param object $profileuser WP_User object |
|
216 | - * @return array List all the possible display names for a certain User object |
|
217 | - */ |
|
218 | - public function generate_display_names( $profileuser ) { |
|
219 | - |
|
220 | - $public_display = array(); |
|
221 | - $public_display['nickname'] = $profileuser->nickname; |
|
222 | - $public_display['username'] = $profileuser->user_login; |
|
223 | - |
|
224 | - if ( !empty($profileuser->first_name) ) { |
|
225 | - $public_display['firstname'] = $profileuser->first_name; |
|
226 | - } |
|
227 | - |
|
228 | - if ( !empty($profileuser->last_name) ) { |
|
229 | - $public_display['lastname'] = $profileuser->last_name; |
|
230 | - } |
|
231 | - |
|
232 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
233 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
234 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
235 | - } |
|
236 | - |
|
237 | - $public_display = array_map( 'trim', $public_display ); |
|
238 | - $public_display = array_unique( $public_display ); |
|
239 | - |
|
240 | - return $public_display; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
246 | - * |
|
247 | - * @see GFUser::update_user() |
|
248 | - * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
249 | - * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
250 | - * @param array $entry The Gravity Forms entry that was just updated |
|
251 | - * @param string $password User password |
|
252 | - * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process |
|
253 | - */ |
|
254 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
255 | - |
|
256 | - /** |
|
257 | - * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
258 | - * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
259 | - * @since 1.14.4 |
|
260 | - * @param boolean $restore_display_name Restore Display Name? Default: true |
|
261 | - */ |
|
262 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
263 | - |
|
264 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
265 | - |
|
266 | - /** |
|
267 | - * Don't restore display name: |
|
268 | - * - either disabled, |
|
269 | - * - or it is an Update feed (we only care about Create feed) |
|
270 | - * - or we don't need as we found the correct format before updating user. |
|
271 | - * @since 1.14.4 |
|
272 | - */ |
|
273 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
274 | - return null; |
|
275 | - } |
|
276 | - |
|
277 | - $user_after_update = get_userdata( $user_id ); |
|
278 | - |
|
279 | - // User not found |
|
280 | - if ( ! $user_after_update ) { |
|
281 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
282 | - return false; |
|
283 | - } |
|
284 | - |
|
285 | - $restored_user = $user_after_update; |
|
286 | - |
|
287 | - // Restore previous display_name |
|
288 | - $restored_user->display_name = $this->_user_before_update->display_name; |
|
289 | - |
|
290 | - // Don't have WP update the password. |
|
291 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
292 | - |
|
293 | - /** |
|
294 | - * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
295 | - * @since 1.14 |
|
296 | - * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
297 | - * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
298 | - * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
299 | - * @param array $entry The Gravity Forms entry that was just updated |
|
300 | - */ |
|
301 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
302 | - |
|
303 | - $updated = wp_update_user( $restored_user ); |
|
304 | - |
|
305 | - if( is_wp_error( $updated ) ) { |
|
306 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
307 | - } else { |
|
308 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
309 | - } |
|
310 | - |
|
311 | - $this->_user_before_update = null; |
|
312 | - |
|
313 | - unset( $restored_user, $user_after_update ); |
|
314 | - |
|
315 | - return $updated; |
|
316 | - } |
|
137 | + public function get_feed_configuration( $entry, $form ) { |
|
138 | + |
|
139 | + /** @var GF_User_Registration $gf_user_registration */ |
|
140 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
141 | + |
|
142 | + $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
143 | + |
|
144 | + /** |
|
145 | + * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
146 | + * @since 1.15 |
|
147 | + * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
148 | + * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
149 | + * @param[in] array $form Gravity Forms form array |
|
150 | + * @param[in] array $entry Gravity Forms entry being edited |
|
151 | + */ |
|
152 | + $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
153 | + |
|
154 | + if( $preserve_role ) { |
|
155 | + $config['meta']['role'] = 'gfur_preserve_role'; |
|
156 | + } |
|
157 | + |
|
158 | + $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
159 | + |
|
160 | + /** |
|
161 | + * Make sure the current display name is not changed with the update user method. |
|
162 | + * @since 1.15 |
|
163 | + */ |
|
164 | + $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
165 | + |
|
166 | + /** |
|
167 | + * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
168 | + * @since 1.14 |
|
169 | + * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
170 | + * @param[in] array $form Gravity Forms form array |
|
171 | + * @param[in] array $entry Gravity Forms entry being edited |
|
172 | + */ |
|
173 | + $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
174 | + |
|
175 | + return $config; |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Calculate the user display name format |
|
180 | + * |
|
181 | + * @since 1.15 |
|
182 | + * @since 1.20 Returns false if user not found at $user_id |
|
183 | + * |
|
184 | + * @param int $user_id WP User ID |
|
185 | + * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
186 | + */ |
|
187 | + public function match_current_display_name( $user_id ) { |
|
188 | + |
|
189 | + $user = get_userdata( $user_id ); |
|
190 | + |
|
191 | + if( ! $user ) { |
|
192 | + return false; |
|
193 | + } |
|
194 | + |
|
195 | + $names = $this->generate_display_names( $user ); |
|
196 | + |
|
197 | + $format = array_search( $user->display_name, $names, true ); |
|
198 | + |
|
199 | + /** |
|
200 | + * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
201 | + * @see restore_display_name |
|
202 | + */ |
|
203 | + if( false === $format ) { |
|
204 | + $this->_user_before_update = $user; |
|
205 | + } |
|
206 | + |
|
207 | + return $format; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Generate an array of all the user display names possibilities |
|
212 | + * |
|
213 | + * @since 1.15 |
|
214 | + * |
|
215 | + * @param object $profileuser WP_User object |
|
216 | + * @return array List all the possible display names for a certain User object |
|
217 | + */ |
|
218 | + public function generate_display_names( $profileuser ) { |
|
219 | + |
|
220 | + $public_display = array(); |
|
221 | + $public_display['nickname'] = $profileuser->nickname; |
|
222 | + $public_display['username'] = $profileuser->user_login; |
|
223 | + |
|
224 | + if ( !empty($profileuser->first_name) ) { |
|
225 | + $public_display['firstname'] = $profileuser->first_name; |
|
226 | + } |
|
227 | + |
|
228 | + if ( !empty($profileuser->last_name) ) { |
|
229 | + $public_display['lastname'] = $profileuser->last_name; |
|
230 | + } |
|
231 | + |
|
232 | + if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
233 | + $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
234 | + $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
235 | + } |
|
236 | + |
|
237 | + $public_display = array_map( 'trim', $public_display ); |
|
238 | + $public_display = array_unique( $public_display ); |
|
239 | + |
|
240 | + return $public_display; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
246 | + * |
|
247 | + * @see GFUser::update_user() |
|
248 | + * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
249 | + * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
250 | + * @param array $entry The Gravity Forms entry that was just updated |
|
251 | + * @param string $password User password |
|
252 | + * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process |
|
253 | + */ |
|
254 | + public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
255 | + |
|
256 | + /** |
|
257 | + * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
258 | + * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
259 | + * @since 1.14.4 |
|
260 | + * @param boolean $restore_display_name Restore Display Name? Default: true |
|
261 | + */ |
|
262 | + $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
263 | + |
|
264 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
265 | + |
|
266 | + /** |
|
267 | + * Don't restore display name: |
|
268 | + * - either disabled, |
|
269 | + * - or it is an Update feed (we only care about Create feed) |
|
270 | + * - or we don't need as we found the correct format before updating user. |
|
271 | + * @since 1.14.4 |
|
272 | + */ |
|
273 | + if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
274 | + return null; |
|
275 | + } |
|
276 | + |
|
277 | + $user_after_update = get_userdata( $user_id ); |
|
278 | + |
|
279 | + // User not found |
|
280 | + if ( ! $user_after_update ) { |
|
281 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
282 | + return false; |
|
283 | + } |
|
284 | + |
|
285 | + $restored_user = $user_after_update; |
|
286 | + |
|
287 | + // Restore previous display_name |
|
288 | + $restored_user->display_name = $this->_user_before_update->display_name; |
|
289 | + |
|
290 | + // Don't have WP update the password. |
|
291 | + unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
292 | + |
|
293 | + /** |
|
294 | + * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
295 | + * @since 1.14 |
|
296 | + * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
297 | + * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
298 | + * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
299 | + * @param array $entry The Gravity Forms entry that was just updated |
|
300 | + */ |
|
301 | + $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
302 | + |
|
303 | + $updated = wp_update_user( $restored_user ); |
|
304 | + |
|
305 | + if( is_wp_error( $updated ) ) { |
|
306 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
307 | + } else { |
|
308 | + do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
309 | + } |
|
310 | + |
|
311 | + $this->_user_before_update = null; |
|
312 | + |
|
313 | + unset( $restored_user, $user_after_update ); |
|
314 | + |
|
315 | + return $updated; |
|
316 | + } |
|
317 | 317 | |
318 | 318 | } //end class |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @since 1.11 |
53 | 53 | * @param boolean $boolean Whether to trigger update on user registration (default: true) |
54 | 54 | */ |
55 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
55 | + if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | 56 | |
57 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
57 | + add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 ); |
|
58 | 58 | |
59 | 59 | // last resort in case the current user display name don't match any of the defaults |
60 | 60 | add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function update_user( $form = array(), $entry_id = 0 ) { |
74 | 74 | |
75 | - if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
75 | + if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
76 | 76 | do_action( 'gravityview_log_error', __METHOD__ . ': GFAPI or User Registration class not found; not updating the user' ); |
77 | 77 | return; |
78 | - } elseif( empty( $entry_id ) ) { |
|
78 | + } elseif ( empty( $entry_id ) ) { |
|
79 | 79 | do_action( 'gravityview_log_error', __METHOD__ . ': Entry ID is empty; not updating the user', $entry_id ); |
80 | 80 | return; |
81 | 81 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | // If an Update feed, make sure the conditions are met. |
104 | - if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
105 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
104 | + if ( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
105 | + if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | remove_filter( 'send_email_change_email', '__return_false', 3 ); |
119 | 119 | |
120 | 120 | // Prevent double-triggering by removing the hook |
121 | - remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
121 | + remove_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10 ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | */ |
152 | 152 | $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
153 | 153 | |
154 | - if( $preserve_role ) { |
|
155 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
154 | + if ( $preserve_role ) { |
|
155 | + $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role'; |
|
156 | 156 | } |
157 | 157 | |
158 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
158 | + $displayname = $this->match_current_display_name( $entry[ 'created_by' ] ); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Make sure the current display name is not changed with the update user method. |
162 | 162 | * @since 1.15 |
163 | 163 | */ |
164 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
164 | + $config[ 'meta' ][ 'displayname' ] = $displayname ? $displayname : $config[ 'meta' ][ 'displayname' ]; |
|
165 | 165 | |
166 | 166 | /** |
167 | 167 | * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | $user = get_userdata( $user_id ); |
190 | 190 | |
191 | - if( ! $user ) { |
|
191 | + if ( ! $user ) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
201 | 201 | * @see restore_display_name |
202 | 202 | */ |
203 | - if( false === $format ) { |
|
203 | + if ( false === $format ) { |
|
204 | 204 | $this->_user_before_update = $user; |
205 | 205 | } |
206 | 206 | |
@@ -218,20 +218,20 @@ discard block |
||
218 | 218 | public function generate_display_names( $profileuser ) { |
219 | 219 | |
220 | 220 | $public_display = array(); |
221 | - $public_display['nickname'] = $profileuser->nickname; |
|
222 | - $public_display['username'] = $profileuser->user_login; |
|
221 | + $public_display[ 'nickname' ] = $profileuser->nickname; |
|
222 | + $public_display[ 'username' ] = $profileuser->user_login; |
|
223 | 223 | |
224 | - if ( !empty($profileuser->first_name) ) { |
|
225 | - $public_display['firstname'] = $profileuser->first_name; |
|
224 | + if ( ! empty( $profileuser->first_name ) ) { |
|
225 | + $public_display[ 'firstname' ] = $profileuser->first_name; |
|
226 | 226 | } |
227 | 227 | |
228 | - if ( !empty($profileuser->last_name) ) { |
|
229 | - $public_display['lastname'] = $profileuser->last_name; |
|
228 | + if ( ! empty( $profileuser->last_name ) ) { |
|
229 | + $public_display[ 'lastname' ] = $profileuser->last_name; |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
233 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
234 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
232 | + if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) { |
|
233 | + $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
234 | + $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | $public_display = array_map( 'trim', $public_display ); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
263 | 263 | |
264 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
264 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' ); |
|
265 | 265 | |
266 | 266 | /** |
267 | 267 | * Don't restore display name: |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * - or we don't need as we found the correct format before updating user. |
271 | 271 | * @since 1.14.4 |
272 | 272 | */ |
273 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
273 | + if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
274 | 274 | return null; |
275 | 275 | } |
276 | 276 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | // User not found |
280 | 280 | if ( ! $user_after_update ) { |
281 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
281 | + do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | |
303 | 303 | $updated = wp_update_user( $restored_user ); |
304 | 304 | |
305 | - if( is_wp_error( $updated ) ) { |
|
306 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
305 | + if ( is_wp_error( $updated ) ) { |
|
306 | + do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
307 | 307 | } else { |
308 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
308 | + do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | $this->_user_before_update = null; |
@@ -65,6 +65,9 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | + /** |
|
69 | + * @param string $component |
|
70 | + */ |
|
68 | 71 | private function load_components( $component ) { |
69 | 72 | |
70 | 73 | $dir = trailingslashit( self::$file ); |
@@ -141,7 +144,7 @@ discard block |
||
141 | 144 | * "You can edit this post from the post page" fields, for example. |
142 | 145 | * |
143 | 146 | * @param $entry array Gravity Forms entry object |
144 | - * @param $view_id int GravityView view id |
|
147 | + * @param integer $view_id int GravityView view id |
|
145 | 148 | * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
146 | 149 | * @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 | 150 | * @return string |
@@ -18,80 +18,80 @@ discard block |
||
18 | 18 | |
19 | 19 | class GravityView_Edit_Entry { |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | 24 | static $file; |
25 | 25 | |
26 | 26 | static $instance; |
27 | 27 | |
28 | - /** |
|
29 | - * Component instances. |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - public $instances = array(); |
|
28 | + /** |
|
29 | + * Component instances. |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + public $instances = array(); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | function __construct() { |
36 | 36 | |
37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
38 | 38 | |
39 | - if( is_admin() ) { |
|
40 | - $this->load_components( 'admin' ); |
|
41 | - } |
|
39 | + if( is_admin() ) { |
|
40 | + $this->load_components( 'admin' ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - $this->load_components( 'render' ); |
|
44 | + $this->load_components( 'render' ); |
|
45 | 45 | |
46 | - // If GF User Registration Add-on exists |
|
47 | - $this->load_components( 'user-registration' ); |
|
46 | + // If GF User Registration Add-on exists |
|
47 | + $this->load_components( 'user-registration' ); |
|
48 | 48 | |
49 | - $this->add_hooks(); |
|
49 | + $this->add_hooks(); |
|
50 | 50 | |
51 | 51 | // Process hooks for addons that may or may not be present |
52 | 52 | $this->addon_specific_hooks(); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - static function getInstance() { |
|
56 | + static function getInstance() { |
|
57 | 57 | |
58 | - if( empty( self::$instance ) ) { |
|
59 | - self::$instance = new GravityView_Edit_Entry; |
|
60 | - } |
|
58 | + if( empty( self::$instance ) ) { |
|
59 | + self::$instance = new GravityView_Edit_Entry; |
|
60 | + } |
|
61 | 61 | |
62 | - return self::$instance; |
|
63 | - } |
|
62 | + return self::$instance; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - private function load_components( $component ) { |
|
66 | + private function load_components( $component ) { |
|
67 | 67 | |
68 | - $dir = trailingslashit( self::$file ); |
|
68 | + $dir = trailingslashit( self::$file ); |
|
69 | 69 | |
70 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
71 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
70 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
71 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
72 | 72 | |
73 | - // Loads component and pass extension's instance so that component can |
|
74 | - // talk each other. |
|
75 | - require_once $filename; |
|
76 | - $this->instances[ $component ] = new $classname( $this ); |
|
77 | - $this->instances[ $component ]->load(); |
|
73 | + // Loads component and pass extension's instance so that component can |
|
74 | + // talk each other. |
|
75 | + require_once $filename; |
|
76 | + $this->instances[ $component ] = new $classname( $this ); |
|
77 | + $this->instances[ $component ]->load(); |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - private function add_hooks() { |
|
81 | + private function add_hooks() { |
|
82 | 82 | |
83 | - // Add front-end access to Gravity Forms delete file action |
|
84 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
83 | + // Add front-end access to Gravity Forms delete file action |
|
84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
85 | 85 | |
86 | - // Make sure this hook is run for non-admins |
|
87 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
86 | + // Make sure this hook is run for non-admins |
|
87 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
88 | 88 | |
89 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
89 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
90 | 90 | |
91 | - // add template path to check for field |
|
92 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
91 | + // add template path to check for field |
|
92 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin |
@@ -105,73 +105,73 @@ discard block |
||
105 | 105 | |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Include this extension templates path |
|
110 | - * @param array $file_paths List of template paths ordered |
|
111 | - */ |
|
112 | - public function add_template_path( $file_paths ) { |
|
113 | - |
|
114 | - // Index 100 is the default GravityView template path. |
|
115 | - $file_paths[ 110 ] = self::$file; |
|
116 | - |
|
117 | - return $file_paths; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * |
|
122 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
123 | - * |
|
124 | - * @param $view_id int GravityView view id |
|
125 | - * @param $form_id int Gravity Forms form id |
|
126 | - * @param $entry_id int Gravity Forms entry id |
|
127 | - * @return string |
|
128 | - */ |
|
129 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
130 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * The edit entry link creates a secure link with a nonce |
|
136 | - * |
|
137 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
138 | - * it formats the display of the edit form like it does in the backend, like |
|
139 | - * "You can edit this post from the post page" fields, for example. |
|
140 | - * |
|
141 | - * @param $entry array Gravity Forms entry object |
|
142 | - * @param $view_id int GravityView view id |
|
143 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
144 | - * @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/ } |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
148 | - |
|
149 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
150 | - |
|
151 | - $base = gv_entry_link( $entry, $post_id ); |
|
152 | - |
|
153 | - $url = add_query_arg( array( |
|
154 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
155 | - ), $base ); |
|
156 | - |
|
157 | - /** |
|
158 | - * Allow passing params to dynamically populate entry with values |
|
159 | - * @since 1.9.2 |
|
160 | - */ |
|
161 | - if( !empty( $field_values ) ) { |
|
162 | - |
|
163 | - if( is_array( $field_values ) ) { |
|
164 | - // If already an array, no parse_str() needed |
|
165 | - $params = $field_values; |
|
166 | - } else { |
|
167 | - parse_str( $field_values, $params ); |
|
168 | - } |
|
169 | - |
|
170 | - $url = add_query_arg( $params, $url ); |
|
171 | - } |
|
172 | - |
|
173 | - return $url; |
|
174 | - } |
|
108 | + /** |
|
109 | + * Include this extension templates path |
|
110 | + * @param array $file_paths List of template paths ordered |
|
111 | + */ |
|
112 | + public function add_template_path( $file_paths ) { |
|
113 | + |
|
114 | + // Index 100 is the default GravityView template path. |
|
115 | + $file_paths[ 110 ] = self::$file; |
|
116 | + |
|
117 | + return $file_paths; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * |
|
122 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
123 | + * |
|
124 | + * @param $view_id int GravityView view id |
|
125 | + * @param $form_id int Gravity Forms form id |
|
126 | + * @param $entry_id int Gravity Forms entry id |
|
127 | + * @return string |
|
128 | + */ |
|
129 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
130 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * The edit entry link creates a secure link with a nonce |
|
136 | + * |
|
137 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
138 | + * it formats the display of the edit form like it does in the backend, like |
|
139 | + * "You can edit this post from the post page" fields, for example. |
|
140 | + * |
|
141 | + * @param $entry array Gravity Forms entry object |
|
142 | + * @param $view_id int GravityView view id |
|
143 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
144 | + * @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/ } |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
148 | + |
|
149 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
150 | + |
|
151 | + $base = gv_entry_link( $entry, $post_id ); |
|
152 | + |
|
153 | + $url = add_query_arg( array( |
|
154 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
155 | + ), $base ); |
|
156 | + |
|
157 | + /** |
|
158 | + * Allow passing params to dynamically populate entry with values |
|
159 | + * @since 1.9.2 |
|
160 | + */ |
|
161 | + if( !empty( $field_values ) ) { |
|
162 | + |
|
163 | + if( is_array( $field_values ) ) { |
|
164 | + // If already an array, no parse_str() needed |
|
165 | + $params = $field_values; |
|
166 | + } else { |
|
167 | + parse_str( $field_values, $params ); |
|
168 | + } |
|
169 | + |
|
170 | + $url = add_query_arg( $params, $url ); |
|
171 | + } |
|
172 | + |
|
173 | + return $url; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Edit mode doesn't allow certain field types. |
@@ -225,81 +225,81 @@ discard block |
||
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * checks if user has permissions to edit a specific entry |
|
230 | - * |
|
231 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
232 | - * |
|
233 | - * @param array $entry Gravity Forms entry array |
|
234 | - * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
235 | - * @return bool |
|
236 | - */ |
|
237 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
228 | + /** |
|
229 | + * checks if user has permissions to edit a specific entry |
|
230 | + * |
|
231 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
232 | + * |
|
233 | + * @param array $entry Gravity Forms entry array |
|
234 | + * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
235 | + * @return bool |
|
236 | + */ |
|
237 | + public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
238 | 238 | |
239 | - // No permission by default |
|
240 | - $user_can_edit = false; |
|
239 | + // No permission by default |
|
240 | + $user_can_edit = false; |
|
241 | 241 | |
242 | - // If they can edit any entries (as defined in Gravity Forms) |
|
243 | - // Or if they can edit other people's entries |
|
244 | - // Then we're good. |
|
245 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
242 | + // If they can edit any entries (as defined in Gravity Forms) |
|
243 | + // Or if they can edit other people's entries |
|
244 | + // Then we're good. |
|
245 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
246 | 246 | |
247 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
247 | + do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
248 | 248 | |
249 | - $user_can_edit = true; |
|
249 | + $user_can_edit = true; |
|
250 | 250 | |
251 | - } else if( !isset( $entry['created_by'] ) ) { |
|
251 | + } else if( !isset( $entry['created_by'] ) ) { |
|
252 | 252 | |
253 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
253 | + do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
254 | 254 | |
255 | - $user_can_edit = false; |
|
255 | + $user_can_edit = false; |
|
256 | 256 | |
257 | - } else { |
|
257 | + } else { |
|
258 | 258 | |
259 | - // get user_edit setting |
|
260 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
261 | - // if View ID not specified or is the current view |
|
262 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
263 | - } else { |
|
264 | - // in case is specified and not the current view |
|
265 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
266 | - } |
|
259 | + // get user_edit setting |
|
260 | + if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
261 | + // if View ID not specified or is the current view |
|
262 | + $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
263 | + } else { |
|
264 | + // in case is specified and not the current view |
|
265 | + $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
266 | + } |
|
267 | 267 | |
268 | - $current_user = wp_get_current_user(); |
|
268 | + $current_user = wp_get_current_user(); |
|
269 | 269 | |
270 | - // User edit is disabled |
|
271 | - if( empty( $user_edit ) ) { |
|
270 | + // User edit is disabled |
|
271 | + if( empty( $user_edit ) ) { |
|
272 | 272 | |
273 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
273 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
274 | 274 | |
275 | - $user_can_edit = false; |
|
276 | - } |
|
275 | + $user_can_edit = false; |
|
276 | + } |
|
277 | 277 | |
278 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
279 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
278 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
279 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
280 | 280 | |
281 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
281 | + do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
282 | 282 | |
283 | - $user_can_edit = true; |
|
283 | + $user_can_edit = true; |
|
284 | 284 | |
285 | - } else if( ! is_user_logged_in() ) { |
|
285 | + } else if( ! is_user_logged_in() ) { |
|
286 | 286 | |
287 | - do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
288 | - } |
|
287 | + do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
288 | + } |
|
289 | 289 | |
290 | - } |
|
290 | + } |
|
291 | 291 | |
292 | - /** |
|
293 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
294 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
295 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
296 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
297 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
298 | - */ |
|
299 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
292 | + /** |
|
293 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
294 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
295 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
296 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
297 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
298 | + */ |
|
299 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
300 | 300 | |
301 | - return (bool)$user_can_edit; |
|
302 | - } |
|
301 | + return (bool)$user_can_edit; |
|
302 | + } |
|
303 | 303 | |
304 | 304 | |
305 | 305 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | self::$file = plugin_dir_path( __FILE__ ); |
38 | 38 | |
39 | - if( is_admin() ) { |
|
39 | + if ( is_admin() ) { |
|
40 | 40 | $this->load_components( 'admin' ); |
41 | 41 | } |
42 | 42 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | static function getInstance() { |
57 | 57 | |
58 | - if( empty( self::$instance ) ) { |
|
58 | + if ( empty( self::$instance ) ) { |
|
59 | 59 | self::$instance = new GravityView_Edit_Entry; |
60 | 60 | } |
61 | 61 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | private function add_hooks() { |
82 | 82 | |
83 | 83 | // Add front-end access to Gravity Forms delete file action |
84 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
85 | 85 | |
86 | 86 | // Make sure this hook is run for non-admins |
87 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
87 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
88 | 88 | |
89 | 89 | add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
90 | 90 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function addon_specific_hooks() { |
101 | 101 | |
102 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
103 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
102 | + if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
103 | + add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
148 | 148 | |
149 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
149 | + $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] ); |
|
150 | 150 | |
151 | 151 | $base = gv_entry_link( $entry, $post_id ); |
152 | 152 | |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | * Allow passing params to dynamically populate entry with values |
159 | 159 | * @since 1.9.2 |
160 | 160 | */ |
161 | - if( !empty( $field_values ) ) { |
|
161 | + if ( ! empty( $field_values ) ) { |
|
162 | 162 | |
163 | - if( is_array( $field_values ) ) { |
|
163 | + if ( is_array( $field_values ) ) { |
|
164 | 164 | // If already an array, no parse_str() needed |
165 | 165 | $params = $field_values; |
166 | 166 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function modify_field_blacklist( $fields = array(), $context = NULL ) { |
183 | 183 | |
184 | - if( empty( $context ) || $context !== 'edit' ) { |
|
184 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
185 | 185 | return $fields; |
186 | 186 | } |
187 | 187 | |
@@ -242,24 +242,24 @@ discard block |
||
242 | 242 | // If they can edit any entries (as defined in Gravity Forms) |
243 | 243 | // Or if they can edit other people's entries |
244 | 244 | // Then we're good. |
245 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
245 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) { |
|
246 | 246 | |
247 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
247 | + do_action( 'gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.' ); |
|
248 | 248 | |
249 | 249 | $user_can_edit = true; |
250 | 250 | |
251 | - } else if( !isset( $entry['created_by'] ) ) { |
|
251 | + } else if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
252 | 252 | |
253 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
253 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.' ); |
|
254 | 254 | |
255 | 255 | $user_can_edit = false; |
256 | 256 | |
257 | 257 | } else { |
258 | 258 | |
259 | 259 | // get user_edit setting |
260 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
260 | + if ( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
261 | 261 | // if View ID not specified or is the current view |
262 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
262 | + $user_edit = GravityView_View::getInstance()->getAtts( 'user_edit' ); |
|
263 | 263 | } else { |
264 | 264 | // in case is specified and not the current view |
265 | 265 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
@@ -268,21 +268,21 @@ discard block |
||
268 | 268 | $current_user = wp_get_current_user(); |
269 | 269 | |
270 | 270 | // User edit is disabled |
271 | - if( empty( $user_edit ) ) { |
|
271 | + if ( empty( $user_edit ) ) { |
|
272 | 272 | |
273 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
273 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
274 | 274 | |
275 | 275 | $user_can_edit = false; |
276 | 276 | } |
277 | 277 | |
278 | 278 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
279 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
279 | + else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
280 | 280 | |
281 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
281 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
282 | 282 | |
283 | 283 | $user_can_edit = true; |
284 | 284 | |
285 | - } else if( ! is_user_logged_in() ) { |
|
285 | + } else if ( ! is_user_logged_in() ) { |
|
286 | 286 | |
287 | 287 | do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
288 | 288 | } |
@@ -169,7 +169,6 @@ |
||
169 | 169 | * |
170 | 170 | * @since 1.15.2 |
171 | 171 | * |
172 | - * @param array $handles Array of meta keys to check for existence of shortcodes |
|
173 | 172 | * @param int $post_id The ID being checked by GravityView |
174 | 173 | * |
175 | 174 | * @return array Meta key array, merged with existing meta keys |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | private function maybe_add_hooks() { |
92 | 92 | $class_exists = $this->class_name && class_exists( $this->class_name ); |
93 | 93 | $function_exists = $this->function_name && function_exists( $this->function_name ); |
94 | - $constant_defined = $this->constant_name && defined("{$this->constant_name}"); |
|
94 | + $constant_defined = $this->constant_name && defined( "{$this->constant_name}" ); |
|
95 | 95 | |
96 | - if( $class_exists || $function_exists || $constant_defined ) { |
|
96 | + if ( $class_exists || $function_exists || $constant_defined ) { |
|
97 | 97 | $this->add_hooks(); |
98 | 98 | } |
99 | 99 | } |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @return void |
105 | 105 | */ |
106 | 106 | protected function add_hooks() { |
107 | - if( $this->content_meta_keys ) { |
|
107 | + if ( $this->content_meta_keys ) { |
|
108 | 108 | add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 ); |
109 | 109 | } |
110 | 110 | |
111 | - if( $this->script_handles ) { |
|
111 | + if ( $this->script_handles ) { |
|
112 | 112 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) ); |
113 | 113 | } |
114 | 114 | |
115 | - if( $this->style_handles ) { |
|
115 | + if ( $this->style_handles ) { |
|
116 | 116 | add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) ); |
117 | 117 | } |
118 | 118 | |
119 | - if( $this->post_type_support ) { |
|
119 | + if ( $this->post_type_support ) { |
|
120 | 120 | add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 ); |
121 | 121 | } |
122 | 122 | } |
@@ -51,6 +51,9 @@ |
||
51 | 51 | // hold widget View options |
52 | 52 | private $widget_options; |
53 | 53 | |
54 | + /** |
|
55 | + * @param string $widget_id |
|
56 | + */ |
|
54 | 57 | function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) { |
55 | 58 | |
56 | 59 |
@@ -116,12 +116,12 @@ |
||
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 |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | // hold widget View options |
52 | 52 | private $widget_options; |
53 | 53 | |
54 | - function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) { |
|
54 | + function __construct( $widget_label, $widget_id, $defaults = array(), $settings = array() ) { |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * The shortcode name is set to the lowercase name of the widget class, unless overridden by the class specifying a different value for $shortcode_name |
59 | 59 | * @var string |
60 | 60 | */ |
61 | - $this->shortcode_name = !isset( $this->shortcode_name ) ? strtolower( get_class($this) ) : $this->shortcode_name; |
|
61 | + $this->shortcode_name = ! isset( $this->shortcode_name ) ? strtolower( get_class( $this ) ) : $this->shortcode_name; |
|
62 | 62 | |
63 | 63 | $this->widget_label = $widget_label; |
64 | 64 | $this->widget_id = $widget_id; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->settings = wp_parse_args( $settings, $this->settings ); |
70 | 70 | |
71 | 71 | // register widgets to be listed in the View Configuration |
72 | - add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget') ); |
|
72 | + add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget' ) ); |
|
73 | 73 | |
74 | 74 | // widget options |
75 | 75 | add_filter( 'gravityview_template_widget_options', array( $this, 'assign_widget_options' ), 10, 3 ); |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | add_action( "gravityview_render_widget_{$widget_id}", array( $this, 'render_frontend' ), 10, 1 ); |
79 | 79 | |
80 | 80 | // register shortcodes |
81 | - add_action( 'wp', array( $this, 'add_shortcode') ); |
|
81 | + add_action( 'wp', array( $this, 'add_shortcode' ) ); |
|
82 | 82 | |
83 | 83 | // Use shortcodes in text widgets. |
84 | - add_filter('widget_text', array( $this, 'maybe_do_shortcode' ) ); |
|
84 | + add_filter( 'widget_text', array( $this, 'maybe_do_shortcode' ) ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | * @param boolean $enable_custom_class False by default. Return true if you want to enable. |
100 | 100 | * @param GravityView_Widget $this Current instance of GravityView_Widget |
101 | 101 | */ |
102 | - $enable_custom_class = apply_filters('gravityview/widget/enable_custom_class', false, $this ); |
|
102 | + $enable_custom_class = apply_filters( 'gravityview/widget/enable_custom_class', false, $this ); |
|
103 | 103 | |
104 | - if( $enable_custom_class ) { |
|
104 | + if ( $enable_custom_class ) { |
|
105 | 105 | |
106 | - $settings['custom_class'] = array( |
|
106 | + $settings[ 'custom_class' ] = array( |
|
107 | 107 | 'type' => 'text', |
108 | 108 | 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
109 | - 'desc' => __( 'This class will be added to the widget container', 'gravityview'), |
|
109 | + 'desc' => __( 'This class will be added to the widget container', 'gravityview' ), |
|
110 | 110 | 'value' => '', |
111 | 111 | 'merge_tags' => true, |
112 | 112 | ); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return array|null Settings array; NULL if not set |
129 | 129 | */ |
130 | 130 | public function get_settings() { |
131 | - return !empty( $this->settings ) ? $this->settings : NULL; |
|
131 | + return ! empty( $this->settings ) ? $this->settings : NULL; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public function get_setting( $key ) { |
140 | 140 | $setting = NULL; |
141 | 141 | |
142 | - if( isset( $this->settings ) && is_array( $this->settings ) ) { |
|
142 | + if ( isset( $this->settings ) && is_array( $this->settings ) ) { |
|
143 | 143 | $setting = isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : NULL; |
144 | 144 | } |
145 | 145 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function maybe_do_shortcode( $text, $widget = NULL ) { |
156 | 156 | |
157 | - if( !empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) { |
|
157 | + if ( ! empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) { |
|
158 | 158 | return do_shortcode( $text ); |
159 | 159 | } |
160 | 160 | |
@@ -183,26 +183,26 @@ discard block |
||
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
186 | - if( empty( $this->shortcode_name ) ) { return; } |
|
186 | + if ( empty( $this->shortcode_name ) ) { return; } |
|
187 | 187 | |
188 | 188 | // If the widget shouldn't output on single entries, don't show it |
189 | - if( empty( $this->show_on_single ) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry() ) { |
|
190 | - do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this)) ); |
|
189 | + if ( empty( $this->show_on_single ) && class_exists( 'GravityView_frontend' ) && GravityView_frontend::is_single_entry() ) { |
|
190 | + do_action( 'gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class( $this ) ) ); |
|
191 | 191 | |
192 | 192 | add_shortcode( $this->shortcode_name, '__return_null' ); |
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
196 | 196 | |
197 | - if( !has_gravityview_shortcode( $post ) ) { |
|
197 | + if ( ! has_gravityview_shortcode( $post ) ) { |
|
198 | 198 | |
199 | - do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this)) ); |
|
199 | + do_action( 'gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class( $this ) ) ); |
|
200 | 200 | |
201 | 201 | add_shortcode( $this->shortcode_name, '__return_null' ); |
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | - add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode') ); |
|
205 | + add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode' ) ); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | function register_widget( $widgets ) { |
214 | 214 | $widgets[ $this->widget_id ] = array( |
215 | - 'label' => $this->widget_label , |
|
215 | + 'label' => $this->widget_label, |
|
216 | 216 | 'description' => $this->widget_description, |
217 | 217 | 'subtitle' => $this->widget_subtitle, |
218 | 218 | ); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function assign_widget_options( $options = array(), $template = '', $widget = '' ) { |
231 | 231 | |
232 | - if( $this->widget_id === $widget ) { |
|
232 | + if ( $this->widget_id === $widget ) { |
|
233 | 233 | $options = array_merge( $options, $this->settings ); |
234 | 234 | } |
235 | 235 | |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return void |
244 | 244 | */ |
245 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
245 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
246 | 246 | // to be defined by child class |
247 | - if( !$this->pre_render_frontend() ) { |
|
247 | + if ( ! $this->pre_render_frontend() ) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | public function pre_render_frontend() { |
257 | 257 | $gravityview_view = GravityView_View::getInstance(); |
258 | 258 | |
259 | - if( empty( $gravityview_view ) ) { |
|
260 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)) ); |
|
259 | + if ( empty( $gravityview_view ) ) { |
|
260 | + do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) ); |
|
261 | 261 | return false; |
262 | 262 | } |
263 | 263 | |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | */ |
269 | 269 | $hide_until_search = apply_filters( 'gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this ); |
270 | 270 | |
271 | - if( $hide_until_search ) { |
|
272 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class($this)) ); |
|
271 | + if ( $hide_until_search ) { |
|
272 | + do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class( $this ) ) ); |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
313 | 313 | |
314 | 314 | |
315 | - /** |
|
316 | - * When an entry is created, check if we need to update the custom slug meta |
|
317 | - * todo: move this to its own class.. |
|
318 | - */ |
|
319 | - add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
315 | + /** |
|
316 | + * When an entry is created, check if we need to update the custom slug meta |
|
317 | + * todo: move this to its own class.. |
|
318 | + */ |
|
319 | + add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * @action `gravityview_include_frontend_actions` Triggered after all GravityView frontend files are loaded |
@@ -347,34 +347,34 @@ discard block |
||
347 | 347 | |
348 | 348 | /** DEBUG */ |
349 | 349 | |
350 | - /** |
|
351 | - * Logs messages using Gravity Forms logging add-on |
|
352 | - * @param string $message log message |
|
353 | - * @param mixed $data Additional data to display |
|
354 | - * @return void |
|
355 | - */ |
|
356 | - public static function log_debug( $message, $data = null ){ |
|
357 | - /** |
|
358 | - * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
|
359 | - * @param string $message Message to display |
|
360 | - * @param mixed $data Supporting data to print alongside it |
|
361 | - */ |
|
362 | - do_action( 'gravityview_log_debug', $message, $data ); |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * Logs messages using Gravity Forms logging add-on |
|
367 | - * @param string $message log message |
|
368 | - * @return void |
|
369 | - */ |
|
370 | - public static function log_error( $message, $data = null ){ |
|
371 | - /** |
|
372 | - * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
|
373 | - * @param string $message Error message to display |
|
374 | - * @param mixed $data Supporting data to print alongside it |
|
375 | - */ |
|
376 | - do_action( 'gravityview_log_error', $message, $data ); |
|
377 | - } |
|
350 | + /** |
|
351 | + * Logs messages using Gravity Forms logging add-on |
|
352 | + * @param string $message log message |
|
353 | + * @param mixed $data Additional data to display |
|
354 | + * @return void |
|
355 | + */ |
|
356 | + public static function log_debug( $message, $data = null ){ |
|
357 | + /** |
|
358 | + * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
|
359 | + * @param string $message Message to display |
|
360 | + * @param mixed $data Supporting data to print alongside it |
|
361 | + */ |
|
362 | + do_action( 'gravityview_log_debug', $message, $data ); |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Logs messages using Gravity Forms logging add-on |
|
367 | + * @param string $message log message |
|
368 | + * @return void |
|
369 | + */ |
|
370 | + public static function log_error( $message, $data = null ){ |
|
371 | + /** |
|
372 | + * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
|
373 | + * @param string $message Error message to display |
|
374 | + * @param mixed $data Supporting data to print alongside it |
|
375 | + */ |
|
376 | + do_action( 'gravityview_log_error', $message, $data ); |
|
377 | + } |
|
378 | 378 | |
379 | 379 | } // end class GravityView_Plugin |
380 | 380 |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @param mixed $data Additional data to display |
352 | 352 | * @return void |
353 | 353 | */ |
354 | - public static function log_debug( $message, $data = null ){ |
|
354 | + public static function log_debug( $message, $data = null ) { |
|
355 | 355 | /** |
356 | 356 | * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
357 | 357 | * @param string $message Message to display |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param string $message log message |
366 | 366 | * @return void |
367 | 367 | */ |
368 | - public static function log_error( $message, $data = null ){ |
|
368 | + public static function log_error( $message, $data = null ) { |
|
369 | 369 | /** |
370 | 370 | * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
371 | 371 | * @param string $message Error message to display |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public static function getInstance() { |
92 | 92 | |
93 | - if( empty( self::$instance ) ) { |
|
93 | + if ( empty( self::$instance ) ) { |
|
94 | 94 | self::$instance = new self; |
95 | 95 | } |
96 | 96 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | self::require_files(); |
103 | 103 | |
104 | - if( ! GravityView_Compatibility::is_valid() ) { |
|
104 | + if ( ! GravityView_Compatibility::is_valid() ) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | */ |
117 | 117 | private static function require_files() { |
118 | 118 | require_once( GRAVITYVIEW_DIR . 'includes/helper-functions.php' ); |
119 | - require_once( GRAVITYVIEW_DIR . 'includes/class-common.php'); |
|
120 | - require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php'); |
|
119 | + require_once( GRAVITYVIEW_DIR . 'includes/class-common.php' ); |
|
120 | + require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php' ); |
|
121 | 121 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-compatibility.php' ); |
122 | 122 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-roles-capabilities.php' ); |
123 | 123 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-notices.php' ); |
124 | 124 | require_once( GRAVITYVIEW_DIR . 'includes/class-admin.php' ); |
125 | - require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php'); |
|
126 | - require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php'); |
|
125 | + require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php' ); |
|
126 | + require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php' ); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-approval-status.php' ); |
159 | - include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-approval.php' ); |
|
159 | + include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-approval.php' ); |
|
160 | 160 | |
161 | - include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-notes.php' ); |
|
162 | - include_once( GRAVITYVIEW_DIR .'includes/load-plugin-and-theme-hooks.php' ); |
|
161 | + include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-notes.php' ); |
|
162 | + include_once( GRAVITYVIEW_DIR . 'includes/load-plugin-and-theme-hooks.php' ); |
|
163 | 163 | |
164 | 164 | // Load Extensions |
165 | 165 | // @todo: Convert to a scan of the directory or a method where this all lives |
166 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' ); |
|
167 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' ); |
|
168 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/entry-notes/class-gravityview-field-notes.php' ); |
|
166 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/edit-entry/class-edit-entry.php' ); |
|
167 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/delete-entry/class-delete-entry.php' ); |
|
168 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/entry-notes/class-gravityview-field-notes.php' ); |
|
169 | 169 | |
170 | 170 | // Load WordPress Widgets |
171 | - include_once( GRAVITYVIEW_DIR .'includes/wordpress-widgets/register-wordpress-widgets.php' ); |
|
171 | + include_once( GRAVITYVIEW_DIR . 'includes/wordpress-widgets/register-wordpress-widgets.php' ); |
|
172 | 172 | |
173 | 173 | // Load GravityView Widgets |
174 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/register-gravityview-widgets.php' ); |
|
174 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/register-gravityview-widgets.php' ); |
|
175 | 175 | |
176 | 176 | // Add oEmbed |
177 | 177 | include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' ); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' ); |
185 | 185 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' ); |
186 | 186 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' ); |
187 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */ |
|
187 | + include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php' ); /** @since 1.8.4 */ |
|
188 | 188 | include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' ); |
189 | 189 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-shortcode.php' ); |
190 | 190 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-link-shortcode.php' ); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return bool |
200 | 200 | */ |
201 | 201 | public static function is_network_activated() { |
202 | - return is_multisite() && ( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network( 'gravityview/gravityview.php' ) ); |
|
202 | + return is_multisite() && ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'gravityview/gravityview.php' ) ); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | |
221 | 221 | if ( php_sapi_name() == 'cli' ) { |
222 | 222 | printf( __( "GravityView requires PHP Version %s or newer. You're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), |
223 | - GV_FUTURE_MIN_PHP_VERSION , phpversion() ); |
|
223 | + GV_FUTURE_MIN_PHP_VERSION, phpversion() ); |
|
224 | 224 | } else { |
225 | 225 | printf( '<body style="padding: 0; margin: 0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">' ); |
226 | 226 | printf( '<img src="' . plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) . '" alt="The GravityView Astronaut Says:" style="float: left; height: 60px; margin-right : 10px;" />' ); |
227 | 227 | printf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), |
228 | - '<h3 style="font-size:16px; margin: 0 0 8px 0;">', GV_FUTURE_MIN_PHP_VERSION , "</h3>\n\n", $version ); |
|
228 | + '<h3 style="font-size:16px; margin: 0 0 8px 0;">', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", $version ); |
|
229 | 229 | printf( '</body>' ); |
230 | 230 | } |
231 | 231 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * @since 1.7.5.1 |
296 | 296 | */ |
297 | 297 | public static function include_widget_class() { |
298 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
298 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget.php' ); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | if ( ! $loaded ) { |
319 | 319 | $locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' ); |
320 | - $mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo'; |
|
320 | + $mofile = dirname( __FILE__ ) . '/languages/gravityview-' . $locale . '.mo'; |
|
321 | 321 | load_textdomain( 'gravityview', $mofile ); |
322 | 322 | } |
323 | 323 | |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function frontend_actions( $force = false ) { |
356 | 356 | |
357 | - if( self::is_admin() && ! $force ) { return; } |
|
357 | + if ( self::is_admin() && ! $force ) { return; } |
|
358 | 358 | |
359 | 359 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-image.php' ); |
360 | - include_once( GRAVITYVIEW_DIR .'includes/class-template.php' ); |
|
361 | - include_once( GRAVITYVIEW_DIR .'includes/class-api.php' ); |
|
362 | - include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' ); |
|
360 | + include_once( GRAVITYVIEW_DIR . 'includes/class-template.php' ); |
|
361 | + include_once( GRAVITYVIEW_DIR . 'includes/class-api.php' ); |
|
362 | + include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' ); |
|
363 | 363 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
364 | 364 | |
365 | 365 | |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | */ |
385 | 385 | public static function get_default_widget_areas() { |
386 | 386 | $default_areas = array( |
387 | - array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ), |
|
388 | - array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ), |
|
387 | + array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ), 'subtitle' => '' ) ) ), |
|
388 | + array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ), 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ), 'subtitle' => '' ) ) ), |
|
389 | 389 | ); |
390 | 390 | |
391 | 391 | /** |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @param mixed $data Additional data to display |
404 | 404 | * @return void |
405 | 405 | */ |
406 | - public static function log_debug( $message, $data = null ){ |
|
406 | + public static function log_debug( $message, $data = null ) { |
|
407 | 407 | /** |
408 | 408 | * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
409 | 409 | * @param string $message Message to display |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param string $message log message |
418 | 418 | * @return void |
419 | 419 | */ |
420 | - public static function log_error( $message, $data = null ){ |
|
420 | + public static function log_error( $message, $data = null ) { |
|
421 | 421 | /** |
422 | 422 | * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
423 | 423 | * @param string $message Error message to display |
@@ -428,4 +428,4 @@ discard block |
||
428 | 428 | |
429 | 429 | } // end class GravityView_Plugin |
430 | 430 | |
431 | -add_action('plugins_loaded', array('GravityView_Plugin', 'getInstance'), 1); |
|
431 | +add_action( 'plugins_loaded', array( 'GravityView_Plugin', 'getInstance' ), 1 ); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | - $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
18 | + $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
19 | 19 | |
20 | 20 | ?> |
21 | 21 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>" /> |
@@ -10,12 +10,12 @@ |
||
10 | 10 | |
11 | 11 | function render_input( $override_input = null ) { |
12 | 12 | |
13 | - if( isset( $override_input ) ) { |
|
13 | + if ( isset( $override_input ) ) { |
|
14 | 14 | echo $override_input; |
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | - $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
18 | + $class = ! empty( $this->field[ 'class' ] ) ? $this->field[ 'class' ] : 'widefat'; |
|
19 | 19 | |
20 | 20 | ?> |
21 | 21 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>" /> |
@@ -18,10 +18,10 @@ |
||
18 | 18 | |
19 | 19 | $show_mt = $this->show_merge_tags(); |
20 | 20 | |
21 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
22 | - $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
|
23 | - } |
|
24 | - $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
21 | + if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
22 | + $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
|
23 | + } |
|
24 | + $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
25 | 25 | |
26 | 26 | ?> |
27 | 27 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="number" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | * number input type |
4 | 4 | */ |
5 | 5 | |
6 | -if( !class_exists('GravityView_FieldType_text') ) { |
|
6 | +if ( ! class_exists( 'GravityView_FieldType_text' ) ) { |
|
7 | 7 | include_once( GRAVITYVIEW_DIR . 'includes/admin/field-types/type_text.php' ); |
8 | 8 | } |
9 | 9 | class GravityView_FieldType_number extends GravityView_FieldType_text { |
10 | 10 | |
11 | 11 | function render_input( $override_input = null ) { |
12 | - if( isset( $override_input ) ) { |
|
12 | + if ( isset( $override_input ) ) { |
|
13 | 13 | echo $override_input; |
14 | 14 | return; |
15 | 15 | } |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | |
19 | 19 | $show_mt = $this->show_merge_tags(); |
20 | 20 | |
21 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
21 | + if ( $show_mt && $this->field[ 'merge_tags' ] !== false || $this->field[ 'merge_tags' ] === 'force' ) { |
|
22 | 22 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
23 | 23 | } |
24 | - $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat'; |
|
24 | + $class .= ! empty( $this->field[ 'class' ] ) ? $this->field[ 'class' ] : 'widefat'; |
|
25 | 25 | |
26 | 26 | ?> |
27 | 27 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="number" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | if( !GravityView_Compatibility::is_valid() ) { return; } |
16 | 16 | |
17 | - self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/'; |
|
17 | + self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/'; |
|
18 | 18 | |
19 | 19 | include_once self::$metaboxes_dir . 'class-gravityview-metabox-tab.php'; |
20 | 20 | |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | $get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL; |
229 | 229 | |
230 | 230 | if( isset( $form['id'] ) ) { |
231 | - $form_script = 'var form = ' . GFCommon::json_encode($form) . ';'; |
|
231 | + $form_script = 'var form = ' . GFCommon::json_encode($form) . ';'; |
|
232 | 232 | |
233 | - // The `gf_vars()` method needs a $_GET[id] variable set with the form ID. |
|
234 | - $_GET['id'] = $form['id']; |
|
233 | + // The `gf_vars()` method needs a $_GET[id] variable set with the form ID. |
|
234 | + $_GET['id'] = $form['id']; |
|
235 | 235 | |
236 | 236 | } else { |
237 | - $form_script = 'var form = new Form();'; |
|
237 | + $form_script = 'var form = new Form();'; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>'; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function __construct() { |
19 | 19 | |
20 | - if( !GravityView_Compatibility::is_valid() ) { return; } |
|
20 | + if ( ! GravityView_Compatibility::is_valid() ) { return; } |
|
21 | 21 | |
22 | 22 | self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/'; |
23 | 23 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function initialize() { |
37 | 37 | |
38 | - add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' )); |
|
38 | + add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' ) ); |
|
39 | 39 | |
40 | - add_action( 'add_meta_boxes_gravityview' , array( $this, 'update_priority' ) ); |
|
40 | + add_action( 'add_meta_boxes_gravityview', array( $this, 'update_priority' ) ); |
|
41 | 41 | |
42 | 42 | // information box |
43 | 43 | add_action( 'post_submitbox_misc_actions', array( $this, 'render_shortcode_hint' ) ); |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | function update_priority() { |
52 | 52 | global $wp_meta_boxes; |
53 | 53 | |
54 | - if( ! empty( $wp_meta_boxes['gravityview'] ) ) { |
|
55 | - foreach( array( 'high', 'core', 'low' ) as $position ) { |
|
56 | - if( isset( $wp_meta_boxes['gravityview']['normal'][ $position ] ) ) { |
|
57 | - foreach( $wp_meta_boxes['gravityview']['normal'][ $position ] as $key => $meta_box ) { |
|
58 | - if( ! preg_match( '/^gravityview_/ism', $key ) ) { |
|
59 | - $wp_meta_boxes['gravityview']['advanced'][ $position ][ $key ] = $meta_box; |
|
60 | - unset( $wp_meta_boxes['gravityview']['normal'][ $position ][ $key ] ); |
|
54 | + if ( ! empty( $wp_meta_boxes[ 'gravityview' ] ) ) { |
|
55 | + foreach ( array( 'high', 'core', 'low' ) as $position ) { |
|
56 | + if ( isset( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ] ) ) { |
|
57 | + foreach ( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ] as $key => $meta_box ) { |
|
58 | + if ( ! preg_match( '/^gravityview_/ism', $key ) ) { |
|
59 | + $wp_meta_boxes[ 'gravityview' ][ 'advanced' ][ $position ][ $key ] = $meta_box; |
|
60 | + unset( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ][ $key ] ); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | global $post; |
70 | 70 | |
71 | 71 | // On Comment Edit, for example, $post isn't set. |
72 | - if( empty( $post ) || !is_object( $post ) || !isset( $post->ID ) ) { |
|
72 | + if ( empty( $post ) || ! is_object( $post ) || ! isset( $post->ID ) ) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | */ |
153 | 153 | $metaboxes = apply_filters( 'gravityview/metaboxes/default', $metaboxes ); |
154 | 154 | |
155 | - foreach( $metaboxes as $m ) { |
|
155 | + foreach ( $metaboxes as $m ) { |
|
156 | 156 | |
157 | - $tab = new GravityView_Metabox_Tab( $m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args'] ); |
|
157 | + $tab = new GravityView_Metabox_Tab( $m[ 'id' ], $m[ 'title' ], $m[ 'file' ], $m[ 'icon-class' ], $m[ 'callback' ], $m[ 'callback_args' ] ); |
|
158 | 158 | |
159 | 159 | GravityView_Metabox_Tabs::add( $tab ); |
160 | 160 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | |
181 | 181 | $links = GravityView_Admin_Views::get_connected_form_links( $current_form, false ); |
182 | 182 | |
183 | - if( !empty( $links ) ) { |
|
184 | - $links = '<span class="alignright gv-form-links">'. $links .'</span>'; |
|
183 | + if ( ! empty( $links ) ) { |
|
184 | + $links = '<span class="alignright gv-form-links">' . $links . '</span>'; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | return __( 'Data Source', 'gravityview' ) . $links; |
@@ -220,28 +220,28 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public static function render_merge_tags_scripts( $curr_form ) { |
222 | 222 | |
223 | - if( empty( $curr_form )) { |
|
223 | + if ( empty( $curr_form ) ) { |
|
224 | 224 | return NULL; |
225 | 225 | } |
226 | 226 | |
227 | 227 | $form = gravityview_get_form( $curr_form ); |
228 | 228 | |
229 | - $get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL; |
|
229 | + $get_id_backup = isset( $_GET[ 'id' ] ) ? $_GET[ 'id' ] : NULL; |
|
230 | 230 | |
231 | - if( isset( $form['id'] ) ) { |
|
232 | - $form_script = 'var form = ' . GFCommon::json_encode($form) . ';'; |
|
231 | + if ( isset( $form[ 'id' ] ) ) { |
|
232 | + $form_script = 'var form = ' . GFCommon::json_encode( $form ) . ';'; |
|
233 | 233 | |
234 | 234 | // The `gf_vars()` method needs a $_GET[id] variable set with the form ID. |
235 | - $_GET['id'] = $form['id']; |
|
235 | + $_GET[ 'id' ] = $form[ 'id' ]; |
|
236 | 236 | |
237 | 237 | } else { |
238 | 238 | $form_script = 'var form = new Form();'; |
239 | 239 | } |
240 | 240 | |
241 | - $output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>'; |
|
241 | + $output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars( false ) . '</script>'; |
|
242 | 242 | |
243 | 243 | // Restore previous $_GET setting |
244 | - $_GET['id'] = $get_id_backup; |
|
244 | + $_GET[ 'id' ] = $get_id_backup; |
|
245 | 245 | |
246 | 246 | return $output; |
247 | 247 | } |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | global $post; |
298 | 298 | |
299 | 299 | // Only show this on GravityView post types. |
300 | - if( false === gravityview_is_admin_page() ) { return; } |
|
300 | + if ( false === gravityview_is_admin_page() ) { return; } |
|
301 | 301 | |
302 | 302 | // If the View hasn't been configured yet, don't show embed shortcode |
303 | - if( !gravityview_get_directory_fields( $post->ID ) ) { return; } |
|
303 | + if ( ! gravityview_get_directory_fields( $post->ID ) ) { return; } |
|
304 | 304 | |
305 | 305 | include self::$metaboxes_dir . 'views/shortcode-hint.php'; |
306 | 306 | } |
@@ -12,7 +12,9 @@ |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
15 | +if ( ! defined( 'ABSPATH' ) ) { |
|
16 | + exit; |
|
17 | +} |
|
16 | 18 | |
17 | 19 | /** |
18 | 20 | * GravityView_Welcome Class |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | * @since 1.0 |
35 | 35 | */ |
36 | 36 | public function __construct() { |
37 | - add_action( 'admin_menu', array( $this, 'admin_menus'), 200 ); |
|
37 | + add_action( 'admin_menu', array( $this, 'admin_menus' ), 200 ); |
|
38 | 38 | add_action( 'admin_head', array( $this, 'admin_head' ) ); |
39 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
40 | - add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page'), 10, 2 ); |
|
39 | + add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
40 | + add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page' ), 10, 2 ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | // Add help page to GravityView menu |
54 | 54 | add_submenu_page( |
55 | 55 | 'edit.php?post_type=gravityview', |
56 | - __('GravityView: Getting Started', 'gravityview'), |
|
57 | - __('Getting Started', 'gravityview'), |
|
56 | + __( 'GravityView: Getting Started', 'gravityview' ), |
|
57 | + __( 'Getting Started', 'gravityview' ), |
|
58 | 58 | $this->minimum_capability, |
59 | 59 | 'gv-getting-started', |
60 | 60 | array( $this, 'getting_started_screen' ) |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return boolean $is_page True: yep; false: nope |
89 | 89 | */ |
90 | - public function is_dashboard_page($is_page = false, $hook = NULL) { |
|
90 | + public function is_dashboard_page( $is_page = false, $hook = NULL ) { |
|
91 | 91 | global $plugin_page; |
92 | 92 | |
93 | - if($is_page) { return $is_page; } |
|
93 | + if ( $is_page ) { return $is_page; } |
|
94 | 94 | |
95 | 95 | return in_array( $plugin_page, array( 'gv-about', 'gv-credits', 'gv-getting-started' ) ); |
96 | 96 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-credits' ); |
109 | 109 | remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-changelog' ); |
110 | 110 | |
111 | - if( !$this->is_dashboard_page() ) { return; } |
|
111 | + if ( ! $this->is_dashboard_page() ) { return; } |
|
112 | 112 | |
113 | 113 | ?> |
114 | 114 | <style type="text/css" media="screen" xmlns="http://www.w3.org/1999/html"> |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | // Don't fetch -beta, etc. |
142 | 142 | list( $display_version ) = explode( '-', GravityView_Plugin::version ); |
143 | 143 | |
144 | - $selected = !empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
144 | + $selected = ! empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
145 | 145 | |
146 | 146 | echo gravityview_get_floaty( 132 ); |
147 | 147 | ?> |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | <div class="about-text"><?php esc_html_e( 'Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview' ); ?></div> |
151 | 151 | |
152 | 152 | <h2 class="nav-tab-wrapper clear"> |
153 | - <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
153 | + <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
154 | 154 | <?php _e( "Getting Started", 'gravityview' ); ?> |
155 | 155 | </a> |
156 | - <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
156 | + <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
157 | 157 | <?php _e( "List of Changes", 'gravityview' ); ?> |
158 | 158 | </a> |
159 | - <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
159 | + <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview' ), 'edit.php' ) ) ); ?>"> |
|
160 | 160 | <?php _e( 'Credits', 'gravityview' ); ?> |
161 | 161 | </a> |
162 | 162 | </h2> |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | <h2>Create a View</h2> |
196 | 196 | |
197 | 197 | <ol class="ol-decimal"> |
198 | - <li>Go to <a href="<?php echo admin_url('post-new.php?post_type=gravityview'); ?>">Views > New View</a></li> |
|
198 | + <li>Go to <a href="<?php echo admin_url( 'post-new.php?post_type=gravityview' ); ?>">Views > New View</a></li> |
|
199 | 199 | <li>If you want to <strong>create a new form</strong>, click the "Use a Form Preset" button</li> |
200 | 200 | <li>If you want to <strong>use an existing form’s entries</strong>, select from the dropdown.</li> |
201 | 201 | <li>Select the type of View you would like to create. There are two core types of Views: <strong>Table</strong> and <strong>Listing</strong>. |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | </ul> |
424 | 424 | |
425 | 425 | <h4><?php esc_attr_e( 'Want to contribute?', 'gravityview' ); ?></h4> |
426 | - <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
426 | + <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview' ), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
427 | 427 | </div> |
428 | 428 | </div> |
429 | 429 | |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | global $plugin_page; |
467 | 467 | |
468 | 468 | // Bail if we're just editing the plugin |
469 | - if( $plugin_page === 'plugin-editor.php' ) { return; } |
|
469 | + if ( $plugin_page === 'plugin-editor.php' ) { return; } |
|
470 | 470 | |
471 | 471 | // Bail if no activation redirect |
472 | 472 | if ( ! get_transient( '_gv_activation_redirect' ) ) { return; } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $upgrade = get_option( 'gv_version_upgraded_from' ); |
478 | 478 | |
479 | 479 | // Don't do anything if they've already seen the new version info |
480 | - if( $upgrade === GravityView_Plugin::version ) { |
|
480 | + if ( $upgrade === GravityView_Plugin::version ) { |
|
481 | 481 | return; |
482 | 482 | } |
483 | 483 | |
@@ -485,10 +485,10 @@ discard block |
||
485 | 485 | update_option( 'gv_version_upgraded_from', GravityView_Plugin::version ); |
486 | 486 | |
487 | 487 | // Bail if activating from network, or bulk |
488 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { return; } |
|
488 | + if ( is_network_admin() || isset( $_GET[ 'activate-multi' ] ) ) { return; } |
|
489 | 489 | |
490 | 490 | // First time install |
491 | - if( ! $upgrade ) { |
|
491 | + if ( ! $upgrade ) { |
|
492 | 492 | wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) ); exit; |
493 | 493 | } |
494 | 494 | // Update |