@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package GravityView |
|
4 | - * @subpackage Gravityview/admin/metaboxes/views |
|
5 | - * @global $post |
|
6 | - */ |
|
3 | + * @package GravityView |
|
4 | + * @subpackage Gravityview/admin/metaboxes/views |
|
5 | + * @global $post |
|
6 | + */ |
|
7 | 7 | global $post; |
8 | 8 | |
9 | 9 | $curr_form = gravityview_get_form_id( $post->ID ); |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Adds a button to add the View shortcode into the post content |
|
4 | - * |
|
5 | - * @package GravityView |
|
6 | - * @license GPL2+ |
|
7 | - * @author Katz Web Services, Inc. |
|
8 | - * @link http://gravityview.co |
|
9 | - * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | - * |
|
11 | - * @since 1.0.0 |
|
12 | - */ |
|
3 | + * Adds a button to add the View shortcode into the post content |
|
4 | + * |
|
5 | + * @package GravityView |
|
6 | + * @license GPL2+ |
|
7 | + * @author Katz Web Services, Inc. |
|
8 | + * @link http://gravityview.co |
|
9 | + * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | + * |
|
11 | + * @since 1.0.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | if( class_exists( 'GravityView_Entry_Notes' ) ){ |
323 | 323 | global $current_user; |
324 | - get_currentuserinfo(); |
|
324 | + get_currentuserinfo(); |
|
325 | 325 | GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $current_user->display_name, $note ); |
326 | 326 | } |
327 | 327 | |
@@ -356,12 +356,12 @@ discard block |
||
356 | 356 | |
357 | 357 | $approvedcolumn = self::get_approved_column( $form['id'] ); |
358 | 358 | |
359 | - /** |
|
360 | - * If the form doesn't contain the approve field, don't assume anything. |
|
361 | - */ |
|
362 | - if( empty( $approvedcolumn ) ) { |
|
363 | - return; |
|
364 | - } |
|
359 | + /** |
|
360 | + * If the form doesn't contain the approve field, don't assume anything. |
|
361 | + */ |
|
362 | + if( empty( $approvedcolumn ) ) { |
|
363 | + return; |
|
364 | + } |
|
365 | 365 | |
366 | 366 | $entry = GFAPI::get_entry( $entry_id ); |
367 | 367 | |
@@ -474,17 +474,17 @@ discard block |
||
474 | 474 | */ |
475 | 475 | static public function get_approved_column( $form ) { |
476 | 476 | |
477 | - if( empty( $form ) ) { |
|
478 | - return null; |
|
479 | - } |
|
477 | + if( empty( $form ) ) { |
|
478 | + return null; |
|
479 | + } |
|
480 | 480 | |
481 | - if( !is_array( $form ) ) { |
|
482 | - $form = GVCommon::get_form( $form ); |
|
483 | - } |
|
481 | + if( !is_array( $form ) ) { |
|
482 | + $form = GVCommon::get_form( $form ); |
|
483 | + } |
|
484 | 484 | |
485 | 485 | foreach( $form['fields'] as $key => $field ) { |
486 | 486 | |
487 | - $field = (array) $field; |
|
487 | + $field = (array) $field; |
|
488 | 488 | |
489 | 489 | if( !empty( $field['gravityview_approved'] ) ) { |
490 | 490 | if( !empty($field['inputs'][0]['id']) ) { |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | - // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
|
496 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
497 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
498 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
499 | - return $input['id']; |
|
500 | - } |
|
501 | - } |
|
502 | - } |
|
495 | + // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
|
496 | + if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
497 | + foreach ( $field['inputs'] as $key2 => $input ) { |
|
498 | + if ( strtolower( $input['label'] ) == 'approved' ) { |
|
499 | + return $input['id']; |
|
500 | + } |
|
501 | + } |
|
502 | + } |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | return null; |
@@ -215,39 +215,39 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | $wp_allowed_scripts = array( |
218 | - 'common', |
|
219 | - 'admin-bar', |
|
220 | - 'autosave', |
|
221 | - 'post', |
|
218 | + 'common', |
|
219 | + 'admin-bar', |
|
220 | + 'autosave', |
|
221 | + 'post', |
|
222 | 222 | 'inline-edit-post', |
223 | - 'utils', |
|
224 | - 'svg-painter', |
|
225 | - 'wp-auth-check', |
|
226 | - 'heartbeat', |
|
223 | + 'utils', |
|
224 | + 'svg-painter', |
|
225 | + 'wp-auth-check', |
|
226 | + 'heartbeat', |
|
227 | 227 | 'media-editor', |
228 | 228 | 'media-upload', |
229 | - 'thickbox', |
|
229 | + 'thickbox', |
|
230 | 230 | 'wp-color-picker', |
231 | 231 | |
232 | - // Settings |
|
232 | + // Settings |
|
233 | 233 | 'gv-admin-edd-license', |
234 | 234 | |
235 | - // Common |
|
236 | - 'select2-js', |
|
237 | - 'qtip-js', |
|
235 | + // Common |
|
236 | + 'select2-js', |
|
237 | + 'qtip-js', |
|
238 | 238 | |
239 | - // jQuery |
|
239 | + // jQuery |
|
240 | 240 | 'jquery', |
241 | - 'jquery-ui-core', |
|
242 | - 'jquery-ui-sortable', |
|
243 | - 'jquery-ui-datepicker', |
|
244 | - 'jquery-ui-dialog', |
|
245 | - 'jquery-ui-slider', |
|
241 | + 'jquery-ui-core', |
|
242 | + 'jquery-ui-sortable', |
|
243 | + 'jquery-ui-datepicker', |
|
244 | + 'jquery-ui-dialog', |
|
245 | + 'jquery-ui-slider', |
|
246 | 246 | 'jquery-ui-dialog', |
247 | 247 | 'jquery-ui-tabs', |
248 | 248 | 'jquery-ui-draggable', |
249 | 249 | 'jquery-ui-droppable', |
250 | - 'jquery-ui-accordion', |
|
250 | + 'jquery-ui-accordion', |
|
251 | 251 | ); |
252 | 252 | |
253 | 253 | $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
@@ -281,23 +281,23 @@ discard block |
||
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | - $wp_allowed_styles = array( |
|
285 | - 'admin-bar', |
|
286 | - 'colors', |
|
287 | - 'ie', |
|
288 | - 'wp-auth-check', |
|
289 | - 'media-views', |
|
284 | + $wp_allowed_styles = array( |
|
285 | + 'admin-bar', |
|
286 | + 'colors', |
|
287 | + 'ie', |
|
288 | + 'wp-auth-check', |
|
289 | + 'media-views', |
|
290 | 290 | 'thickbox', |
291 | 291 | 'dashicons', |
292 | - 'wp-jquery-ui-dialog', |
|
293 | - 'jquery-ui-sortable', |
|
292 | + 'wp-jquery-ui-dialog', |
|
293 | + 'jquery-ui-sortable', |
|
294 | 294 | |
295 | - // Settings |
|
296 | - 'gravityview_settings', |
|
295 | + // Settings |
|
296 | + 'gravityview_settings', |
|
297 | 297 | |
298 | - // @todo qTip styles not loading for some reason! |
|
299 | - 'jquery-qtip.js', |
|
300 | - ); |
|
298 | + // @todo qTip styles not loading for some reason! |
|
299 | + 'jquery-qtip.js', |
|
300 | + ); |
|
301 | 301 | |
302 | 302 | $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
303 | 303 | |
@@ -317,32 +317,32 @@ discard block |
||
317 | 317 | */ |
318 | 318 | private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
319 | 319 | |
320 | - /** |
|
321 | - * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
322 | - * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
323 | - * @param array $required_objects |
|
324 | - */ |
|
325 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
326 | - |
|
327 | - //reset queue |
|
328 | - $queue = array(); |
|
329 | - foreach( $wp_objects->queue as $object ) { |
|
330 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
331 | - $queue[] = $object; |
|
332 | - } |
|
333 | - } |
|
334 | - $wp_objects->queue = $queue; |
|
335 | - |
|
336 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
337 | - |
|
338 | - //unregistering scripts |
|
339 | - $registered = array(); |
|
340 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | - if( in_array( $handle, $required_objects ) ){ |
|
342 | - $registered[ $handle ] = $script_registration; |
|
343 | - } |
|
344 | - } |
|
345 | - $wp_objects->registered = $registered; |
|
320 | + /** |
|
321 | + * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
322 | + * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
323 | + * @param array $required_objects |
|
324 | + */ |
|
325 | + $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
326 | + |
|
327 | + //reset queue |
|
328 | + $queue = array(); |
|
329 | + foreach( $wp_objects->queue as $object ) { |
|
330 | + if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
331 | + $queue[] = $object; |
|
332 | + } |
|
333 | + } |
|
334 | + $wp_objects->queue = $queue; |
|
335 | + |
|
336 | + $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
337 | + |
|
338 | + //unregistering scripts |
|
339 | + $registered = array(); |
|
340 | + foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | + if( in_array( $handle, $required_objects ) ){ |
|
342 | + $registered[ $handle ] = $script_registration; |
|
343 | + } |
|
344 | + } |
|
345 | + $wp_objects->registered = $registered; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -405,7 +405,6 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @deprecated since 1.12 |
407 | 407 | * @see GravityView_Compatibility::get_plugin_status() |
408 | - |
|
409 | 408 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
410 | 409 | */ |
411 | 410 | static function get_plugin_status( $location = '' ) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | // template areas |
138 | 138 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
139 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
139 | + $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
140 | 140 | |
141 | 141 | // widget areas |
142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
@@ -328,40 +328,40 @@ discard block |
||
328 | 328 | // load file |
329 | 329 | $xmlstr = file_get_contents( $form_file ); |
330 | 330 | |
331 | - $options = array( |
|
332 | - "page" => array("unserialize_as_array" => true), |
|
333 | - "form"=> array("unserialize_as_array" => true), |
|
334 | - "field"=> array("unserialize_as_array" => true), |
|
335 | - "rule"=> array("unserialize_as_array" => true), |
|
336 | - "choice"=> array("unserialize_as_array" => true), |
|
337 | - "input"=> array("unserialize_as_array" => true), |
|
338 | - "routing_item"=> array("unserialize_as_array" => true), |
|
339 | - "creditCard"=> array("unserialize_as_array" => true), |
|
340 | - "routin"=> array("unserialize_as_array" => true), |
|
341 | - "confirmation" => array("unserialize_as_array" => true), |
|
342 | - "notification" => array("unserialize_as_array" => true) |
|
343 | - ); |
|
331 | + $options = array( |
|
332 | + "page" => array("unserialize_as_array" => true), |
|
333 | + "form"=> array("unserialize_as_array" => true), |
|
334 | + "field"=> array("unserialize_as_array" => true), |
|
335 | + "rule"=> array("unserialize_as_array" => true), |
|
336 | + "choice"=> array("unserialize_as_array" => true), |
|
337 | + "input"=> array("unserialize_as_array" => true), |
|
338 | + "routing_item"=> array("unserialize_as_array" => true), |
|
339 | + "creditCard"=> array("unserialize_as_array" => true), |
|
340 | + "routin"=> array("unserialize_as_array" => true), |
|
341 | + "confirmation" => array("unserialize_as_array" => true), |
|
342 | + "notification" => array("unserialize_as_array" => true) |
|
343 | + ); |
|
344 | 344 | |
345 | 345 | $xml = new RGXML($options); |
346 | - $forms = $xml->unserialize($xmlstr); |
|
346 | + $forms = $xml->unserialize($xmlstr); |
|
347 | 347 | |
348 | - if( !$forms ) { |
|
349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
350 | - return false; |
|
351 | - } |
|
348 | + if( !$forms ) { |
|
349 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
350 | + return false; |
|
351 | + } |
|
352 | 352 | |
353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
354 | - $form = $forms[0]; |
|
355 | - } |
|
353 | + if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
354 | + $form = $forms[0]; |
|
355 | + } |
|
356 | 356 | |
357 | - if( empty( $form ) ) { |
|
358 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
359 | - return false; |
|
360 | - } |
|
357 | + if( empty( $form ) ) { |
|
358 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
359 | + return false; |
|
360 | + } |
|
361 | 361 | |
362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
362 | + do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
363 | 363 | |
364 | - return $form; |
|
364 | + return $form; |
|
365 | 365 | |
366 | 366 | } |
367 | 367 |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | |
214 | 214 | if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
215 | 215 | foreach ( $field['inputs'] as $input ) { |
216 | - /** |
|
217 | - * @hack |
|
218 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
219 | - */ |
|
220 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
221 | - continue; |
|
222 | - } |
|
216 | + /** |
|
217 | + * @hack |
|
218 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
219 | + */ |
|
220 | + if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
221 | + continue; |
|
222 | + } |
|
223 | 223 | $fields[ (string)$input['id'] ] = array( |
224 | 224 | 'label' => rgar( $input, 'label' ), |
225 | 225 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
467 | 467 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
468 | 468 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
469 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
469 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
470 | 470 | $criteria['context_view_id'] = null; |
471 | 471 | } |
472 | 472 | |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | ), |
1083 | 1083 | ); |
1084 | 1084 | |
1085 | - $fields = $date_created + $fields; |
|
1085 | + $fields = $date_created + $fields; |
|
1086 | 1086 | |
1087 | 1087 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1088 | 1088 | |
@@ -1094,13 +1094,13 @@ discard block |
||
1094 | 1094 | } |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - /** |
|
1098 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1099 | - * @since 1.12 |
|
1100 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1101 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1102 | - */ |
|
1103 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1097 | + /** |
|
1098 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1099 | + * @since 1.12 |
|
1100 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1101 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1102 | + */ |
|
1103 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1104 | 1104 | |
1105 | 1105 | return $fields; |
1106 | 1106 | } |
@@ -1365,17 +1365,17 @@ discard block |
||
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | |
1368 | - /** |
|
1369 | - * Display updated/error notice |
|
1370 | - * |
|
1371 | - * @param string $notice text/HTML of notice |
|
1372 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1373 | - * |
|
1374 | - * @return string |
|
1375 | - */ |
|
1376 | - public static function generate_notice( $notice, $class = '' ) { |
|
1377 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1378 | - } |
|
1368 | + /** |
|
1369 | + * Display updated/error notice |
|
1370 | + * |
|
1371 | + * @param string $notice text/HTML of notice |
|
1372 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1373 | + * |
|
1374 | + * @return string |
|
1375 | + */ |
|
1376 | + public static function generate_notice( $notice, $class = '' ) { |
|
1377 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1378 | + } |
|
1379 | 1379 | |
1380 | 1380 | |
1381 | 1381 |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * GravityView Frontend functions |
|
4 | - * |
|
5 | - * @package GravityView |
|
6 | - * @license GPL2+ |
|
7 | - * @author Katz Web Services, Inc. |
|
8 | - * @link http://gravityview.co |
|
9 | - * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | - * |
|
11 | - * @since 1.0.0 |
|
12 | - */ |
|
3 | + * GravityView Frontend functions |
|
4 | + * |
|
5 | + * @package GravityView |
|
6 | + * @license GPL2+ |
|
7 | + * @author Katz Web Services, Inc. |
|
8 | + * @link http://gravityview.co |
|
9 | + * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | + * |
|
11 | + * @since 1.0.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | |
15 | 15 | class GravityView_frontend { |
@@ -5,220 +5,220 @@ |
||
5 | 5 | */ |
6 | 6 | class GravityView_Change_Entry_Creator { |
7 | 7 | |
8 | - function __construct() { |
|
9 | - |
|
10 | - /** |
|
11 | - * @since 1.5.1 |
|
12 | - */ |
|
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
14 | - |
|
15 | - // ONLY ADMIN FROM HERE ON. |
|
16 | - if( !is_admin() ) { return; } |
|
17 | - |
|
18 | - /** |
|
19 | - * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
20 | - * @since 1.7.4 |
|
21 | - * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
22 | - */ |
|
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
24 | - return; |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * Use `init` to fix bbPress warning |
|
29 | - * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
30 | - */ |
|
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
32 | - |
|
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
8 | + function __construct() { |
|
9 | + |
|
10 | + /** |
|
11 | + * @since 1.5.1 |
|
12 | + */ |
|
13 | + add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
14 | + |
|
15 | + // ONLY ADMIN FROM HERE ON. |
|
16 | + if( !is_admin() ) { return; } |
|
17 | + |
|
18 | + /** |
|
19 | + * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
20 | + * @since 1.7.4 |
|
21 | + * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
22 | + */ |
|
23 | + if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
24 | + return; |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * Use `init` to fix bbPress warning |
|
29 | + * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
30 | + */ |
|
31 | + add_action('init', array( $this, 'load'), 100 ); |
|
32 | + |
|
33 | + add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
34 | 34 | |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * When an user is created using the User Registration add-on, assign the entry to them |
|
39 | - * |
|
40 | - * @since 1.5.1 |
|
41 | - * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
42 | - * @param int $user_id WordPress User ID |
|
43 | - * @param array $config User registration feed configuration |
|
44 | - * @param array $entry GF Entry array |
|
45 | - * @param string $password User password |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
37 | + /** |
|
38 | + * When an user is created using the User Registration add-on, assign the entry to them |
|
39 | + * |
|
40 | + * @since 1.5.1 |
|
41 | + * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
42 | + * @param int $user_id WordPress User ID |
|
43 | + * @param array $config User registration feed configuration |
|
44 | + * @param array $entry GF Entry array |
|
45 | + * @param string $password User password |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
49 | 49 | |
50 | - /** |
|
51 | - * Disable assigning the new user to the entry by returning false. |
|
52 | - * @param int $user_id WordPress User ID |
|
53 | - * @param array $config User registration feed configuration |
|
54 | - * @param array $entry GF Entry array |
|
55 | - */ |
|
56 | - $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
57 | - |
|
58 | - // If filter returns false, do not process |
|
59 | - if( empty( $assign_to_lead ) ) { |
|
60 | - return; |
|
61 | - } |
|
50 | + /** |
|
51 | + * Disable assigning the new user to the entry by returning false. |
|
52 | + * @param int $user_id WordPress User ID |
|
53 | + * @param array $config User registration feed configuration |
|
54 | + * @param array $entry GF Entry array |
|
55 | + */ |
|
56 | + $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
57 | + |
|
58 | + // If filter returns false, do not process |
|
59 | + if( empty( $assign_to_lead ) ) { |
|
60 | + return; |
|
61 | + } |
|
62 | 62 | |
63 | - // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
64 | - $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
63 | + // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
64 | + $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
65 | 65 | |
66 | - if( empty( $result ) ) { |
|
67 | - $status = __('Error', 'gravityview'); |
|
68 | - } else { |
|
69 | - $status = __('Success', 'gravityview'); |
|
70 | - } |
|
71 | - |
|
72 | - $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 ); |
|
66 | + if( empty( $result ) ) { |
|
67 | + $status = __('Error', 'gravityview'); |
|
68 | + } else { |
|
69 | + $status = __('Success', 'gravityview'); |
|
70 | + } |
|
71 | + |
|
72 | + $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 ); |
|
73 | 73 | |
74 | - do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
74 | + do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
75 | 75 | |
76 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
76 | + GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Disable previous functionality; use this one as the canonical. |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - function prevent_conflicts() { |
|
80 | + /** |
|
81 | + * Disable previous functionality; use this one as the canonical. |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + function prevent_conflicts() { |
|
85 | 85 | |
86 | - // Plugin that was provided here: |
|
87 | - // @link https://gravityview.co/support/documentation/201991205/ |
|
88 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10, 2); |
|
89 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10, 2); |
|
86 | + // Plugin that was provided here: |
|
87 | + // @link https://gravityview.co/support/documentation/201991205/ |
|
88 | + remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10, 2); |
|
89 | + remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10, 2); |
|
90 | 90 | |
91 | - // Disable for Gravity Forms Add-ons 3.6.2 and lower |
|
92 | - if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
91 | + // Disable for Gravity Forms Add-ons 3.6.2 and lower |
|
92 | + if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
93 | 93 | |
94 | - $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
|
94 | + $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
|
95 | 95 | |
96 | - // Now, no validation is required in the methods; let's hook in. |
|
97 | - remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
96 | + // Now, no validation is required in the methods; let's hook in. |
|
97 | + remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
98 | 98 | |
99 | - remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10, 2); |
|
99 | + remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10, 2); |
|
100 | 100 | |
101 | - remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10, 2); |
|
102 | - } |
|
101 | + remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10, 2); |
|
102 | + } |
|
103 | 103 | |
104 | - } |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @since 3.6.3 |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - function load() { |
|
106 | + /** |
|
107 | + * @since 3.6.3 |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + function load() { |
|
111 | 111 | |
112 | - // Does GF exist? |
|
113 | - if( !class_exists('GFCommon') ) { |
|
114 | - return; |
|
115 | - } |
|
112 | + // Does GF exist? |
|
113 | + if( !class_exists('GFCommon') ) { |
|
114 | + return; |
|
115 | + } |
|
116 | 116 | |
117 | - // Can the user edit entries? |
|
118 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
119 | - return; |
|
120 | - } |
|
117 | + // Can the user edit entries? |
|
118 | + if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
119 | + return; |
|
120 | + } |
|
121 | 121 | |
122 | - // If screen mode isn't set, then we're in the wrong place. |
|
123 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
124 | - return; |
|
125 | - } |
|
122 | + // If screen mode isn't set, then we're in the wrong place. |
|
123 | + if( empty( $_REQUEST['screen_mode'] ) ) { |
|
124 | + return; |
|
125 | + } |
|
126 | 126 | |
127 | - // Now, no validation is required in the methods; let's hook in. |
|
128 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
127 | + // Now, no validation is required in the methods; let's hook in. |
|
128 | + add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
129 | 129 | |
130 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
130 | + add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
131 | 131 | |
132 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
132 | + add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
133 | 133 | |
134 | - } |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
138 | - * @return void |
|
139 | - */ |
|
140 | - function set_screen_mode() { |
|
136 | + /** |
|
137 | + * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
138 | + * @return void |
|
139 | + */ |
|
140 | + function set_screen_mode() { |
|
141 | 141 | |
142 | - // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
143 | - if( rgget('screen_mode') === 'edit' ) { |
|
144 | - $_POST["screen_mode"] = 'edit'; |
|
145 | - } |
|
142 | + // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
143 | + if( rgget('screen_mode') === 'edit' ) { |
|
144 | + $_POST["screen_mode"] = 'edit'; |
|
145 | + } |
|
146 | 146 | |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * When the entry creator is changed, add a note to the entry |
|
151 | - * @param array $form GF entry array |
|
152 | - * @param int $entry_id Entry ID |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - function update_entry_creator($form, $entry_id) { |
|
156 | - global $current_user; |
|
149 | + /** |
|
150 | + * When the entry creator is changed, add a note to the entry |
|
151 | + * @param array $form GF entry array |
|
152 | + * @param int $entry_id Entry ID |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + function update_entry_creator($form, $entry_id) { |
|
156 | + global $current_user; |
|
157 | 157 | |
158 | - // Update the entry |
|
159 | - $created_by = absint( rgpost('created_by') ); |
|
158 | + // Update the entry |
|
159 | + $created_by = absint( rgpost('created_by') ); |
|
160 | 160 | |
161 | - RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
161 | + RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
162 | 162 | |
163 | - // If the creator has changed, let's add a note about who it used to be. |
|
164 | - $originally_created_by = rgpost('originally_created_by'); |
|
163 | + // If the creator has changed, let's add a note about who it used to be. |
|
164 | + $originally_created_by = rgpost('originally_created_by'); |
|
165 | 165 | |
166 | - // If there's no owner and there didn't used to be, keep going |
|
167 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
168 | - return; |
|
169 | - } |
|
166 | + // If there's no owner and there didn't used to be, keep going |
|
167 | + if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
168 | + return; |
|
169 | + } |
|
170 | 170 | |
171 | - // If the values have changed |
|
172 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
171 | + // If the values have changed |
|
172 | + if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
173 | 173 | |
174 | - $user_data = get_userdata($current_user->ID); |
|
174 | + $user_data = get_userdata($current_user->ID); |
|
175 | 175 | |
176 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
176 | + $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
177 | 177 | |
178 | - $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'); |
|
178 | + $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'); |
|
179 | 179 | |
180 | - if( !empty( $originally_created_by ) ) { |
|
181 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
182 | - $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
183 | - } |
|
180 | + if( !empty( $originally_created_by ) ) { |
|
181 | + $originally_created_by_user_data = get_userdata($originally_created_by); |
|
182 | + $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
183 | + } |
|
184 | 184 | |
185 | - if( !empty( $created_by ) ) { |
|
186 | - $created_by_user_data = get_userdata($created_by); |
|
187 | - $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
188 | - } |
|
185 | + if( !empty( $created_by ) ) { |
|
186 | + $created_by_user_data = get_userdata($created_by); |
|
187 | + $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
188 | + } |
|
189 | 189 | |
190 | - 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' ); |
|
191 | - } |
|
190 | + 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' ); |
|
191 | + } |
|
192 | 192 | |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * Output the select to change the entry creator |
|
197 | - * @param int $form_id GF Form ID |
|
198 | - * @param array $entry GF entry array |
|
199 | - * @return void |
|
200 | - */ |
|
201 | - function add_select($form_id, $entry ) { |
|
195 | + /** |
|
196 | + * Output the select to change the entry creator |
|
197 | + * @param int $form_id GF Form ID |
|
198 | + * @param array $entry GF entry array |
|
199 | + * @return void |
|
200 | + */ |
|
201 | + function add_select($form_id, $entry ) { |
|
202 | 202 | |
203 | - if( rgpost('screen_mode') !== 'edit' ) { |
|
204 | - return; |
|
205 | - } |
|
203 | + if( rgpost('screen_mode') !== 'edit' ) { |
|
204 | + return; |
|
205 | + } |
|
206 | 206 | |
207 | - $users = GVCommon::get_users( 'change_entry_creator' ); |
|
207 | + $users = GVCommon::get_users( 'change_entry_creator' ); |
|
208 | 208 | |
209 | - $output = '<label for="change_created_by">'; |
|
210 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
211 | - $output .= '</label> |
|
209 | + $output = '<label for="change_created_by">'; |
|
210 | + $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
211 | + $output .= '</label> |
|
212 | 212 | <select name="created_by" id="change_created_by" class="widefat">'; |
213 | - $output .= '<option value=""> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
214 | - foreach($users as $user) { |
|
215 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
216 | - } |
|
217 | - $output .= '</select>'; |
|
218 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
219 | - echo $output; |
|
220 | - |
|
221 | - } |
|
213 | + $output .= '<option value=""> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
214 | + foreach($users as $user) { |
|
215 | + $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
216 | + } |
|
217 | + $output .= '</select>'; |
|
218 | + $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
219 | + echo $output; |
|
220 | + |
|
221 | + } |
|
222 | 222 | |
223 | 223 | } |
224 | 224 |
@@ -204,7 +204,7 @@ |
||
204 | 204 | self::$notices['wp_version'] = array( |
205 | 205 | 'class' => 'error', |
206 | 206 | 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), |
207 | - 'cap' => 'update_core', |
|
207 | + 'cap' => 'update_core', |
|
208 | 208 | 'dismiss' => 'wp_version', |
209 | 209 | ); |
210 | 210 |