@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @since 1.5.1 |
12 | 12 | */ |
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
13 | + add_action( 'gform_user_registered', array( $this, 'assign_new_user_to_lead' ), 10, 4 ); |
|
14 | 14 | |
15 | 15 | // ONLY ADMIN FROM HERE ON. |
16 | - if( !is_admin() ) { return; } |
|
16 | + if ( ! is_admin() ) { return; } |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
20 | 20 | * @since 1.7.4 |
21 | 21 | * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
22 | 22 | */ |
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
23 | + if ( apply_filters( 'gravityview_disable_change_entry_creator', false ) ) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | * Use `init` to fix bbPress warning |
29 | 29 | * @see https://bbpress.trac.wordpress.org/ticket/2309 |
30 | 30 | */ |
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
31 | + add_action( 'init', array( $this, 'load' ), 100 ); |
|
32 | 32 | |
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
33 | + add_action( 'plugins_loaded', array( $this, 'prevent_conflicts' ) ); |
|
34 | 34 | |
35 | 35 | // Enqueues SelectWoo script and style. |
36 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_selectwoo_assets') ); |
|
36 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_selectwoo_assets' ) ); |
|
37 | 37 | |
38 | 38 | // Ajax callback to get users to change entry creator. |
39 | 39 | add_action( 'wp_ajax_entry_creator_get_users', array( $this, 'entry_creator_get_users' ) ); |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | ) |
83 | 83 | ); |
84 | 84 | |
85 | - if( !wp_verify_nonce( $post_var['gv_nonce'], 'gv_entry_creator' )) { |
|
85 | + if ( ! wp_verify_nonce( $post_var[ 'gv_nonce' ], 'gv_entry_creator' ) ) { |
|
86 | 86 | die(); |
87 | 87 | } |
88 | 88 | |
89 | - $search_string = $post_var['q']; |
|
89 | + $search_string = $post_var[ 'q' ]; |
|
90 | 90 | |
91 | - if( is_numeric( $search_string ) ) { |
|
91 | + if ( is_numeric( $search_string ) ) { |
|
92 | 92 | $user_args = array( |
93 | 93 | 'search' => $search_string . '*', |
94 | 94 | 'search_columns' => array( 'ID' ), |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
130 | 130 | |
131 | 131 | // If filter returns false, do not process |
132 | - if( empty( $assign_to_lead ) ) { |
|
132 | + if ( empty( $assign_to_lead ) ) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
137 | - $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
137 | + $result = RGFormsModel::update_entry_property( (int)$entry[ 'id' ], 'created_by', (int)$user_id, false, true ); |
|
138 | 138 | |
139 | 139 | if ( false === $result ) { |
140 | - $status = __('Error', 'gravityview'); |
|
140 | + $status = __( 'Error', 'gravityview' ); |
|
141 | 141 | global $wpdb; |
142 | 142 | $note = sprintf( '%s: Failed to assign User ID #%d as the entry creator (Last database error: "%s")', $status, $user_id, $wpdb->last_error ); |
143 | 143 | } else { |
144 | - $status = __('Success', 'gravityview'); |
|
145 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
144 | + $status = __( 'Success', 'gravityview' ); |
|
145 | + $note = sprintf( _x( '%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview' ), $status, $user_id ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note' => $note ) ); |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | * @since 1.21.5 |
153 | 153 | * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
154 | 154 | */ |
155 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
155 | + if ( apply_filters( 'gravityview_disable_change_entry_creator_note', false ) ) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
159 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
159 | + GravityView_Entry_Notes::add_note( $entry[ 'id' ], -1, 'GravityView', $note, 'gravityview' ); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | |
169 | 169 | // Plugin that was provided here: |
170 | 170 | // @link https://gravityview.co/support/documentation/201991205/ |
171 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
172 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
171 | + remove_action( "gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
172 | + remove_action( "gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | |
@@ -180,26 +180,26 @@ discard block |
||
180 | 180 | function load() { |
181 | 181 | |
182 | 182 | // Does GF exist? |
183 | - if( !class_exists('GFCommon') ) { |
|
183 | + if ( ! class_exists( 'GFCommon' ) ) { |
|
184 | 184 | return; |
185 | 185 | } |
186 | 186 | |
187 | 187 | // Can the user edit entries? |
188 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
188 | + if ( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | 192 | // If screen mode isn't set, then we're in the wrong place. |
193 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
193 | + if ( empty( $_REQUEST[ 'screen_mode' ] ) ) { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Now, no validation is required in the methods; let's hook in. |
198 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
198 | + add_action( 'admin_init', array( &$this, 'set_screen_mode' ) ); |
|
199 | 199 | |
200 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
200 | + add_action( "gform_entry_info", array( &$this, 'add_select' ), 10, 2 ); |
|
201 | 201 | |
202 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
202 | + add_action( "gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2 ); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | */ |
210 | 210 | function set_screen_mode() { |
211 | 211 | |
212 | - if( 'view' === \GV\Utils::_POST( 'screen_mode' ) ) { |
|
212 | + if ( 'view' === \GV\Utils::_POST( 'screen_mode' ) ) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | 216 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
217 | - if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
218 | - $_POST["screen_mode"] = 'edit'; |
|
217 | + if ( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
218 | + $_POST[ "screen_mode" ] = 'edit'; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | } |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | * @param int $entry_id Entry ID |
227 | 227 | * @return void |
228 | 228 | */ |
229 | - function update_entry_creator($form, $entry_id) { |
|
229 | + function update_entry_creator( $form, $entry_id ) { |
|
230 | 230 | global $current_user; |
231 | 231 | |
232 | 232 | // Update the entry |
233 | - $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
233 | + $created_by = absint( \GV\Utils::_POST( 'created_by' ) ); |
|
234 | 234 | |
235 | 235 | RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
236 | 236 | |
@@ -238,30 +238,30 @@ discard block |
||
238 | 238 | $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
239 | 239 | |
240 | 240 | // If there's no owner and there didn't used to be, keep going |
241 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
241 | + if ( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | |
245 | 245 | // If the values have changed |
246 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
246 | + if ( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
247 | 247 | |
248 | - $user_data = get_userdata($current_user->ID); |
|
248 | + $user_data = get_userdata( $current_user->ID ); |
|
249 | 249 | |
250 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
250 | + $user_format = _x( '%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview' ); |
|
251 | 251 | |
252 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
252 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview' ); |
|
253 | 253 | |
254 | - if( !empty( $originally_created_by ) ) { |
|
255 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
254 | + if ( ! empty( $originally_created_by ) ) { |
|
255 | + $originally_created_by_user_data = get_userdata( $originally_created_by ); |
|
256 | 256 | $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
257 | 257 | } |
258 | 258 | |
259 | - if( !empty( $created_by ) ) { |
|
260 | - $created_by_user_data = get_userdata($created_by); |
|
259 | + if ( ! empty( $created_by ) ) { |
|
260 | + $created_by_user_data = get_userdata( $created_by ); |
|
261 | 261 | $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
262 | 262 | } |
263 | 263 | |
264 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
264 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __( 'Changed entry creator from %s to %s', 'gravityview' ), $original_name, $created_by_name ), 'note' ); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | } |
@@ -272,31 +272,31 @@ discard block |
||
272 | 272 | * @param array $entry GF entry array |
273 | 273 | * @return void |
274 | 274 | */ |
275 | - function add_select($form_id, $entry ) { |
|
275 | + function add_select( $form_id, $entry ) { |
|
276 | 276 | |
277 | - if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
277 | + if ( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | 281 | |
282 | 282 | $output = '<label for="change_created_by">'; |
283 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
283 | + $output .= esc_html__( 'Change Entry Creator:', 'gravityview' ); |
|
284 | 284 | $output .= '</label>'; |
285 | 285 | |
286 | 286 | $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
287 | 287 | |
288 | 288 | $created_by_id = \GV\Utils::get( $entry, 'created_by' ); |
289 | 289 | $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ); |
290 | - $created_by_user = isset($created_by_user[0]) ? $created_by_user[0] : array(); |
|
290 | + $created_by_user = isset( $created_by_user[ 0 ] ) ? $created_by_user[ 0 ] : array(); |
|
291 | 291 | |
292 | - if( empty( $created_by_user ) ) { |
|
293 | - $output .= '<option value="0"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
292 | + if ( empty( $created_by_user ) ) { |
|
293 | + $output .= '<option value="0"> — ' . esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview' ) . ' — </option>'; |
|
294 | 294 | } else { |
295 | - $output .= '<option value="'. $created_by_user->ID .'" "selected">'.esc_attr( $created_by_user->display_name.' ('.$created_by_user->user_nicename.')' ).'</option>'; |
|
295 | + $output .= '<option value="' . $created_by_user->ID . '" "selected">' . esc_attr( $created_by_user->display_name . ' (' . $created_by_user->user_nicename . ')' ) . '</option>'; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | $output .= '</select>'; |
299 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
299 | + $output .= '<input name="originally_created_by" value="' . esc_attr( $entry[ 'created_by' ] ) . '" type="hidden" />'; |
|
300 | 300 | $output .= wp_nonce_field( 'gv_entry_creator', 'gv_entry_creator_nonce', false, false ); |
301 | 301 | |
302 | 302 | echo $output; |