@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | $hide_coupon_fields = apply_filters( 'gravityview/edit_entry/hide-coupon-fields', $has_transaction_data ); |
| 55 | 55 | |
| 56 | - return (bool) $hide_coupon_fields; |
|
| 56 | + return (bool)$hide_coupon_fields; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function edit_entry_field_blacklist( $blacklist = array(), $entry = array() ) { |
| 70 | 70 | |
| 71 | 71 | if ( $this->should_hide_coupon_fields( $entry ) ) { |
| 72 | - $blacklist[] = 'coupon'; |
|
| 72 | + $blacklist[ ] = 'coupon'; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $blacklist; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | // No coupons match the codes provided |
| 108 | 108 | $discounts = gf_coupons()->get_coupons_by_codes( $coupon_codes, $form ); |
| 109 | 109 | |
| 110 | - if( ! $discounts ) { |
|
| 110 | + if ( ! $discounts ) { |
|
| 111 | 111 | return $value; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @see GF_Field_Coupon::get_field_input |
| 117 | 117 | */ |
| 118 | 118 | $_POST = ! isset( $_POST ) ? array() : $_POST; |
| 119 | - $_POST[ 'gf_coupons_' . $form['id'] ] = json_encode( (array) $discounts ); |
|
| 119 | + $_POST[ 'gf_coupons_' . $form[ 'id' ] ] = json_encode( (array)$discounts ); |
|
| 120 | 120 | $_POST[ 'input_' . $field->id ] = implode( ',', $coupon_codes ); |
| 121 | 121 | |
| 122 | 122 | return $value; |
@@ -306,12 +306,12 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | - * @hack |
|
| 310 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 311 | - */ |
|
| 309 | + * @hack |
|
| 310 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 311 | + */ |
|
| 312 | 312 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
| 313 | - continue; |
|
| 314 | - } |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 315 | 315 | $fields["{$input['id']}"] = array( |
| 316 | 316 | 'label' => rgar( $input, 'label' ), |
| 317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
| 489 | 489 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
| 490 | 490 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
| 491 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
| 491 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
| 492 | 492 | $criteria['context_view_id'] = null; |
| 493 | 493 | } |
| 494 | 494 | |
@@ -1251,7 +1251,7 @@ discard block |
||
| 1251 | 1251 | ), |
| 1252 | 1252 | ); |
| 1253 | 1253 | |
| 1254 | - $fields = $date_created + $fields; |
|
| 1254 | + $fields = $date_created + $fields; |
|
| 1255 | 1255 | |
| 1256 | 1256 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1257 | 1257 | |
@@ -1263,13 +1263,13 @@ discard block |
||
| 1263 | 1263 | } |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | - /** |
|
| 1267 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1268 | - * @since 1.12 |
|
| 1269 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1270 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1271 | - */ |
|
| 1272 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1266 | + /** |
|
| 1267 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1268 | + * @since 1.12 |
|
| 1269 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1270 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1271 | + */ |
|
| 1272 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1273 | 1273 | |
| 1274 | 1274 | return $fields; |
| 1275 | 1275 | } |
@@ -1561,26 +1561,26 @@ discard block |
||
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | 1563 | |
| 1564 | - /** |
|
| 1565 | - * Display updated/error notice |
|
| 1566 | - * |
|
| 1567 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
| 1568 | - * |
|
| 1569 | - * @param string $notice text/HTML of notice |
|
| 1570 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1571 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
| 1572 | - * |
|
| 1573 | - * @return string |
|
| 1574 | - */ |
|
| 1575 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
| 1576 | - |
|
| 1577 | - // If $cap is defined, only show notice if user has capability |
|
| 1578 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1579 | - return ''; |
|
| 1580 | - } |
|
| 1581 | - |
|
| 1582 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1583 | - } |
|
| 1564 | + /** |
|
| 1565 | + * Display updated/error notice |
|
| 1566 | + * |
|
| 1567 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
| 1568 | + * |
|
| 1569 | + * @param string $notice text/HTML of notice |
|
| 1570 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1571 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
| 1572 | + * |
|
| 1573 | + * @return string |
|
| 1574 | + */ |
|
| 1575 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
| 1576 | + |
|
| 1577 | + // If $cap is defined, only show notice if user has capability |
|
| 1578 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1579 | + return ''; |
|
| 1580 | + } |
|
| 1581 | + |
|
| 1582 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1583 | + } |
|
| 1584 | 1584 | |
| 1585 | 1585 | /** |
| 1586 | 1586 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 327 | + if( GFCommon::is_product_field( $field['type'] ) ) { |
|
| 328 | 328 | $has_product_fields = true; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | $fields = array(); |
| 386 | 386 | |
| 387 | - foreach ( $extra_fields as $key => $field ){ |
|
| 387 | + foreach ( $extra_fields as $key => $field ) { |
|
| 388 | 388 | if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
| 389 | 389 | $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
| 390 | 390 | } |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | $form = GFAPI::get_form( $form ); |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 981 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 982 | 982 | return GFFormsModel::get_field( $form, $field_id ); |
| 983 | 983 | } else { |
| 984 | 984 | return null; |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | $shortcodes = array(); |
| 1026 | 1026 | |
| 1027 | 1027 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1028 | - if ( empty( $matches ) ){ |
|
| 1028 | + if ( empty( $matches ) ) { |
|
| 1029 | 1029 | return false; |
| 1030 | 1030 | } |
| 1031 | 1031 | |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $form = false; |
| 128 | 128 | |
| 129 | - if( $entry ) { |
|
| 130 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
| 129 | + if ( $entry ) { |
|
| 130 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | return $form; |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | $has_transaction_data = rgar( $entry, $meta, false ); |
| 195 | 195 | |
| 196 | - if( ! empty( $has_transaction_data ) ) { |
|
| 196 | + if ( ! empty( $has_transaction_data ) ) { |
|
| 197 | 197 | break; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - return (bool) $has_transaction_data; |
|
| 201 | + return (bool)$has_transaction_data; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
| 238 | 238 | |
| 239 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 239 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
| 240 | 240 | |
| 241 | 241 | return $result; |
| 242 | 242 | } |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
| 255 | 255 | */ |
| 256 | - public static function get_forms( $active = true, $trash = false ) { |
|
| 256 | + public static function get_forms( $active = true, $trash = false ) { |
|
| 257 | 257 | $forms = array(); |
| 258 | 258 | if ( class_exists( 'GFAPI' ) ) { |
| 259 | - if( 'any' === $active ) { |
|
| 259 | + if ( 'any' === $active ) { |
|
| 260 | 260 | $active_forms = GFAPI::get_forms( true, $trash ); |
| 261 | 261 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
| 262 | 262 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | $has_post_fields = false; |
| 288 | 288 | |
| 289 | 289 | if ( $form ) { |
| 290 | - foreach ( $form['fields'] as $field ) { |
|
| 291 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 292 | - $fields["{$field['id']}"] = array( |
|
| 290 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 291 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
| 292 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
| 293 | 293 | 'label' => rgar( $field, 'label' ), |
| 294 | 294 | 'parent' => null, |
| 295 | 295 | 'type' => rgar( $field, 'type' ), |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | ); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 302 | - foreach ( $field['inputs'] as $input ) { |
|
| 301 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
| 302 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
| 303 | 303 | |
| 304 | - if( ! empty( $input['isHidden'] ) ) { |
|
| 304 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
| 305 | 305 | continue; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | * @hack |
| 310 | 310 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 311 | 311 | */ |
| 312 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
| 312 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
| 313 | 313 | continue; |
| 314 | 314 | } |
| 315 | - $fields["{$input['id']}"] = array( |
|
| 315 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
| 316 | 316 | 'label' => rgar( $input, 'label' ), |
| 317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
| 318 | 318 | 'parent' => $field, |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 327 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
| 328 | 328 | $has_product_fields = true; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | * @since 1.7 |
| 339 | 339 | */ |
| 340 | 340 | if ( $has_post_fields ) { |
| 341 | - $fields['post_id'] = array( |
|
| 341 | + $fields[ 'post_id' ] = array( |
|
| 342 | 342 | 'label' => __( 'Post ID', 'gravityview' ), |
| 343 | 343 | 'type' => 'post_id', |
| 344 | 344 | ); |
@@ -351,11 +351,11 @@ discard block |
||
| 351 | 351 | foreach ( $payment_fields as $payment_field ) { |
| 352 | 352 | |
| 353 | 353 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
| 354 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 354 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 355 | 355 | continue; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $fields["{$payment_field->name}"] = array( |
|
| 358 | + $fields[ "{$payment_field->name}" ] = array( |
|
| 359 | 359 | 'label' => $payment_field->label, |
| 360 | 360 | 'desc' => $payment_field->description, |
| 361 | 361 | 'type' => $payment_field->name, |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | $fields = array(); |
| 389 | 389 | |
| 390 | - foreach ( $extra_fields as $key => $field ){ |
|
| 391 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 392 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 390 | + foreach ( $extra_fields as $key => $field ) { |
|
| 391 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
| 392 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | |
@@ -429,32 +429,32 @@ discard block |
||
| 429 | 429 | 'search_criteria' => null, |
| 430 | 430 | 'sorting' => null, |
| 431 | 431 | 'paging' => null, |
| 432 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
| 432 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
| 433 | 433 | ); |
| 434 | 434 | |
| 435 | 435 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
| 436 | 436 | |
| 437 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 438 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 437 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 438 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
| 439 | 439 | |
| 440 | 440 | if ( ! is_array( $filter ) ) { |
| 441 | 441 | continue; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // By default, we want searches to be wildcard for each field. |
| 445 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 445 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 449 | 449 | * @param string $operator Existing search operator |
| 450 | 450 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 451 | 451 | */ |
| 452 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 452 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | // don't send just the [mode] without any field filter. |
| 456 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
| 457 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
| 456 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 457 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | } |
@@ -465,36 +465,36 @@ discard block |
||
| 465 | 465 | * Prepare date formats to be in Gravity Forms DB format; |
| 466 | 466 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 467 | 467 | */ |
| 468 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 468 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
| 469 | 469 | |
| 470 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 470 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
| 471 | 471 | |
| 472 | 472 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 473 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 473 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 474 | 474 | |
| 475 | 475 | if ( $date ) { |
| 476 | 476 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 477 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 477 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 478 | 478 | } else { |
| 479 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
| 479 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
| 480 | 480 | |
| 481 | 481 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 482 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 482 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | |
| 488 | 488 | // Calculate the context view id and send it to the advanced filter |
| 489 | - if( GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
| 490 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 489 | + if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
| 490 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 491 | 491 | } elseif ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
| 492 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 492 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 493 | 493 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
| 494 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
| 495 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
| 494 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
| 495 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
| 496 | 496 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
| 497 | - $criteria['context_view_id'] = null; |
|
| 497 | + $criteria[ 'context_view_id' ] = null; |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | * @param array $form_ids Forms to search |
| 504 | 504 | * @param int $view_id ID of the view being used to search |
| 505 | 505 | */ |
| 506 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 506 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
| 507 | 507 | |
| 508 | 508 | return (array)$criteria; |
| 509 | 509 | } |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | /** Reduce # of database calls */ |
| 534 | 534 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
| 535 | 535 | |
| 536 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 536 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
| 537 | 537 | |
| 538 | 538 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
| 539 | 539 | |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | |
| 542 | 542 | // Still update the total count when using cached results |
| 543 | 543 | if ( ! is_null( $total ) ) { |
| 544 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 544 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | $return = $entries; |
@@ -561,9 +561,9 @@ discard block |
||
| 561 | 561 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
| 562 | 562 | |
| 563 | 563 | // No entries returned from gravityview_before_get_entries |
| 564 | - if( is_null( $entries ) ) { |
|
| 564 | + if ( is_null( $entries ) ) { |
|
| 565 | 565 | |
| 566 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 566 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
| 567 | 567 | |
| 568 | 568 | if ( is_wp_error( $entries ) ) { |
| 569 | 569 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 575 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
| 576 | 576 | |
| 577 | 577 | // Cache results |
| 578 | 578 | $Cache->set( $entries, 'entries' ); |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | */ |
| 678 | 678 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
| 679 | 679 | |
| 680 | - if( $check_entry_display ) { |
|
| 680 | + if ( $check_entry_display ) { |
|
| 681 | 681 | // Is the entry allowed |
| 682 | 682 | $entry = self::check_entry_display( $entry ); |
| 683 | 683 | } |
@@ -710,12 +710,12 @@ discard block |
||
| 710 | 710 | |
| 711 | 711 | $value = false; |
| 712 | 712 | |
| 713 | - if( 'context' === $val1 ) { |
|
| 713 | + if ( 'context' === $val1 ) { |
|
| 714 | 714 | |
| 715 | 715 | $matching_contexts = array( $val2 ); |
| 716 | 716 | |
| 717 | 717 | // We allow for non-standard contexts. |
| 718 | - switch( $val2 ) { |
|
| 718 | + switch ( $val2 ) { |
|
| 719 | 719 | // Check for either single or edit |
| 720 | 720 | case 'singular': |
| 721 | 721 | $matching_contexts = array( 'single', 'edit' ); |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | return false; |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - if ( empty( $entry['form_id'] ) ) { |
|
| 779 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 780 | 780 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
| 781 | 781 | return false; |
| 782 | 782 | } |
@@ -784,26 +784,26 @@ discard block |
||
| 784 | 784 | $criteria = self::calculate_get_entries_criteria(); |
| 785 | 785 | |
| 786 | 786 | // Make sure the current View is connected to the same form as the Entry |
| 787 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 788 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 787 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 788 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
| 789 | 789 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
| 790 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 791 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 790 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
| 791 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
| 792 | 792 | return false; |
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 796 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
| 797 | 797 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
| 798 | 798 | return $entry; |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - $search_criteria = $criteria['search_criteria']; |
|
| 801 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
| 802 | 802 | unset( $criteria ); |
| 803 | 803 | |
| 804 | 804 | // check entry status |
| 805 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 806 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 805 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
| 806 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
| 807 | 807 | return false; |
| 808 | 808 | } |
| 809 | 809 | |
@@ -811,41 +811,41 @@ discard block |
||
| 811 | 811 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 812 | 812 | |
| 813 | 813 | // field_filters |
| 814 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 814 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
| 815 | 815 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
| 816 | 816 | return $entry; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - $filters = $search_criteria['field_filters']; |
|
| 819 | + $filters = $search_criteria[ 'field_filters' ]; |
|
| 820 | 820 | unset( $search_criteria ); |
| 821 | 821 | |
| 822 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 823 | - unset( $filters['mode'] ); |
|
| 822 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
| 823 | + unset( $filters[ 'mode' ] ); |
|
| 824 | 824 | |
| 825 | - $form = self::get_form( $entry['form_id'] ); |
|
| 825 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 826 | 826 | |
| 827 | 827 | foreach ( $filters as $filter ) { |
| 828 | 828 | |
| 829 | - if ( ! isset( $filter['key'] ) ) { |
|
| 829 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
| 830 | 830 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter ); |
| 831 | 831 | continue; |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | - $k = $filter['key']; |
|
| 834 | + $k = $filter[ 'key' ]; |
|
| 835 | 835 | |
| 836 | 836 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
| 837 | 837 | $field_value = $entry[ $k ]; |
| 838 | 838 | $field = null; |
| 839 | 839 | } else { |
| 840 | 840 | $field = self::get_field( $form, $k ); |
| 841 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 841 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 842 | 842 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
| 843 | 843 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? rgar( $field_value, $k ) : $field_value; |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 846 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
| 847 | 847 | |
| 848 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 848 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
| 849 | 849 | |
| 850 | 850 | // verify if we are already free to go! |
| 851 | 851 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -903,18 +903,18 @@ discard block |
||
| 903 | 903 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 904 | 904 | * @see GFCommon::format_date() for original code |
| 905 | 905 | */ |
| 906 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 906 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 907 | 907 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 908 | 908 | |
| 909 | - $format = rgar( $atts, 'format' ); |
|
| 910 | - $is_human = ! empty( $atts['human'] ); |
|
| 911 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 912 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 913 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 914 | - $include_time = ! empty( $atts['time'] ); |
|
| 909 | + $format = rgar( $atts, 'format' ); |
|
| 910 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 911 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 912 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 913 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 914 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 915 | 915 | |
| 916 | 916 | // If we're using time diff, we want to have a different default format |
| 917 | - if( empty( $format ) ) { |
|
| 917 | + if ( empty( $format ) ) { |
|
| 918 | 918 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
| 919 | 919 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 920 | 920 | } |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | // If raw was specified, don't modify the stored value |
| 923 | 923 | if ( $is_raw ) { |
| 924 | 924 | $formatted_date = $date_string; |
| 925 | - } elseif( $is_timestamp ) { |
|
| 925 | + } elseif ( $is_timestamp ) { |
|
| 926 | 926 | $formatted_date = $date_local_timestamp; |
| 927 | 927 | } elseif ( $is_diff ) { |
| 928 | 928 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | |
| 957 | 957 | $label = rgar( $field, 'label' ); |
| 958 | 958 | |
| 959 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 959 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 960 | 960 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
| 961 | 961 | } |
| 962 | 962 | |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | $form = GFAPI::get_form( $form ); |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 987 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 988 | 988 | return GFFormsModel::get_field( $form, $field_id ); |
| 989 | 989 | } else { |
| 990 | 990 | return null; |
@@ -1031,19 +1031,19 @@ discard block |
||
| 1031 | 1031 | $shortcodes = array(); |
| 1032 | 1032 | |
| 1033 | 1033 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1034 | - if ( empty( $matches ) ){ |
|
| 1034 | + if ( empty( $matches ) ) { |
|
| 1035 | 1035 | return false; |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | foreach ( $matches as $shortcode ) { |
| 1039 | - if ( $tag === $shortcode[2] ) { |
|
| 1039 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 1040 | 1040 | |
| 1041 | 1041 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 1042 | - $shortcodes[] = $shortcode; |
|
| 1042 | + $shortcodes[ ] = $shortcode; |
|
| 1043 | 1043 | |
| 1044 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 1045 | - foreach( $results as $result ) { |
|
| 1046 | - $shortcodes[] = $result; |
|
| 1044 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 1045 | + foreach ( $results as $result ) { |
|
| 1046 | + $shortcodes[ ] = $result; |
|
| 1047 | 1047 | } |
| 1048 | 1048 | } |
| 1049 | 1049 | } |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
| 1188 | 1188 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
| 1189 | 1189 | |
| 1190 | - if( $apply_filter ) { |
|
| 1190 | + if ( $apply_filter ) { |
|
| 1191 | 1191 | /** |
| 1192 | 1192 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
| 1193 | 1193 | * @since 1.6.5 |
@@ -1210,7 +1210,7 @@ discard block |
||
| 1210 | 1210 | * @return string html |
| 1211 | 1211 | */ |
| 1212 | 1212 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1213 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1213 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1214 | 1214 | |
| 1215 | 1215 | if ( empty( $formid ) ) { |
| 1216 | 1216 | return $output; |
@@ -1223,11 +1223,11 @@ discard block |
||
| 1223 | 1223 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1224 | 1224 | |
| 1225 | 1225 | foreach ( $fields as $id => $field ) { |
| 1226 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1226 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1227 | 1227 | continue; |
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1230 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | } |
| 1233 | 1233 | |
@@ -1262,9 +1262,9 @@ discard block |
||
| 1262 | 1262 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1263 | 1263 | |
| 1264 | 1264 | // TODO: Convert to using array_filter |
| 1265 | - foreach( $fields as $id => $field ) { |
|
| 1265 | + foreach ( $fields as $id => $field ) { |
|
| 1266 | 1266 | |
| 1267 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1267 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1268 | 1268 | unset( $fields[ $id ] ); |
| 1269 | 1269 | } |
| 1270 | 1270 | } |
@@ -1305,14 +1305,14 @@ discard block |
||
| 1305 | 1305 | * @param int|array $field field key or field array |
| 1306 | 1306 | * @return boolean |
| 1307 | 1307 | */ |
| 1308 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1308 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1309 | 1309 | |
| 1310 | 1310 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1311 | 1311 | $form = self::get_form( $form ); |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | // If entry meta, it's a string. Otherwise, numeric |
| 1315 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1315 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1316 | 1316 | $type = $field; |
| 1317 | 1317 | } else { |
| 1318 | 1318 | $type = self::get_field_type( $form, $field ); |
@@ -1326,9 +1326,9 @@ discard block |
||
| 1326 | 1326 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1327 | 1327 | |
| 1328 | 1328 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1329 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1330 | - if( true === $gv_field->is_numeric ) { |
|
| 1331 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1329 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1330 | + if ( true === $gv_field->is_numeric ) { |
|
| 1331 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1332 | 1332 | } |
| 1333 | 1333 | } |
| 1334 | 1334 | |
@@ -1478,18 +1478,18 @@ discard block |
||
| 1478 | 1478 | $final_atts = array_filter( $final_atts ); |
| 1479 | 1479 | |
| 1480 | 1480 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1481 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1482 | - $final_atts['href'] = $href; |
|
| 1481 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1482 | + $final_atts[ 'href' ] = $href; |
|
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1485 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1486 | 1486 | |
| 1487 | 1487 | /** |
| 1488 | 1488 | * Fix potential security issue with target=_blank |
| 1489 | 1489 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
| 1490 | 1490 | */ |
| 1491 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
| 1492 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1491 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
| 1492 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | 1495 | // Sort the attributes alphabetically, to help testing |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | - if( '' !== $output ) { |
|
| 1504 | + if ( '' !== $output ) { |
|
| 1505 | 1505 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1506 | 1506 | } |
| 1507 | 1507 | |
@@ -1528,7 +1528,7 @@ discard block |
||
| 1528 | 1528 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1529 | 1529 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1530 | 1530 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
| 1531 | - $merged[] = $value; |
|
| 1531 | + $merged[ ] = $value; |
|
| 1532 | 1532 | } else { |
| 1533 | 1533 | $merged[ $key ] = $value; |
| 1534 | 1534 | } |
@@ -1561,7 +1561,7 @@ discard block |
||
| 1561 | 1561 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1562 | 1562 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1563 | 1563 | */ |
| 1564 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1564 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1565 | 1565 | |
| 1566 | 1566 | return get_users( $get_users_settings ); |
| 1567 | 1567 | } |
@@ -1581,11 +1581,11 @@ discard block |
||
| 1581 | 1581 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
| 1582 | 1582 | |
| 1583 | 1583 | // If $cap is defined, only show notice if user has capability |
| 1584 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1584 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1585 | 1585 | return ''; |
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1588 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | 1591 | /** |
@@ -2,8 +2,9 @@ discard block |
||
| 2 | 2 | namespace GV; |
| 3 | 3 | |
| 4 | 4 | /** If this file is called directly, abort. */ |
| 5 | -if ( ! defined( 'GRAVITYVIEW_DIR' ) ) |
|
| 5 | +if ( ! defined( 'GRAVITYVIEW_DIR' ) ) { |
|
| 6 | 6 | die(); |
| 7 | +} |
|
| 7 | 8 | |
| 8 | 9 | /** |
| 9 | 10 | * A collection of \GV\View objects. |
@@ -39,8 +40,9 @@ discard block |
||
| 39 | 40 | */ |
| 40 | 41 | public function get( $view_id ) { |
| 41 | 42 | foreach ( $this->all() as $view ) { |
| 42 | - if ( $view->ID == $view_id ) |
|
| 43 | - return $view; |
|
| 43 | + if ( $view->ID == $view_id ) { |
|
| 44 | + return $view; |
|
| 45 | + } |
|
| 44 | 46 | } |
| 45 | 47 | return null; |
| 46 | 48 | } |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | continue; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( ! isset( $shortcode->atts['id'] ) ) { |
|
| 74 | + if ( ! isset( $shortcode->atts[ 'id' ] ) ) { |
|
| 75 | 75 | do_action( 'gravityview_log_error', __METHOD__ . ': [gravityview] shortcode has no `id` attribute' ); |
| 76 | 76 | continue; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( is_numeric( $shortcode->atts['id'] ) ) { |
|
| 80 | - $views->append( View::by_id( $shortcode->atts['id'] ) ); |
|
| 79 | + if ( is_numeric( $shortcode->atts[ 'id' ] ) ) { |
|
| 80 | + $views->append( View::by_id( $shortcode->atts[ 'id' ] ) ); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | continue; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ( is_numeric( $shortcode->atts['id'] ) ) { |
|
| 111 | - $views->append( View::by_id( $shortcode->atts['id'] ) ); |
|
| 110 | + if ( is_numeric( $shortcode->atts[ 'id' ] ) ) { |
|
| 111 | + $views->append( View::by_id( $shortcode->atts[ 'id' ] ) ); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | * @return string The version of PHP. |
| 212 | 212 | */ |
| 213 | 213 | private function get_php_version() { |
| 214 | - return !empty( $GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] ) ? |
|
| 215 | - $GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] : phpversion(); |
|
| 214 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE' ] ) ? |
|
| 215 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE' ] : phpversion(); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | * @return string The version of WordPress. |
| 224 | 224 | */ |
| 225 | 225 | private function get_wordpress_version() { |
| 226 | - return !empty( $GLOBALS['GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] ) ? |
|
| 227 | - $GLOBALS['GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] : $GLOBALS['wp_version']; |
|
| 226 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE' ] ) ? |
|
| 227 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE' ] : $GLOBALS[ 'wp_version' ]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | * @return string The version of Gravity Forms. |
| 237 | 237 | */ |
| 238 | 238 | private function get_gravityforms_version() { |
| 239 | - if ( !class_exists( '\GFCommon' ) || !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) ) |
|
| 239 | + if ( ! class_exists( '\GFCommon' ) || ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE' ] ) ) |
|
| 240 | 240 | throw new \ErrorException( 'Gravity Forms is inactive or not installed.' ); |
| 241 | 241 | |
| 242 | - return !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] ) ? |
|
| 243 | - $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] : \GFCommon::$version; |
|
| 242 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE' ] ) ? |
|
| 243 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE' ] : \GFCommon::$version; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | private function __clone() { } |
@@ -2,8 +2,9 @@ discard block |
||
| 2 | 2 | namespace GV; |
| 3 | 3 | |
| 4 | 4 | /** If this file is called directly, abort. */ |
| 5 | -if ( ! defined( 'GRAVITYVIEW_DIR' ) ) |
|
| 5 | +if ( ! defined( 'GRAVITYVIEW_DIR' ) ) { |
|
| 6 | 6 | die(); |
| 7 | +} |
|
| 7 | 8 | |
| 8 | 9 | /** |
| 9 | 10 | * The GravityView WordPress plugin class. |
@@ -68,8 +69,9 @@ discard block |
||
| 68 | 69 | * @return \GV\Plugin The global instance of GravityView Plugin. |
| 69 | 70 | */ |
| 70 | 71 | public static function get() { |
| 71 | - if ( ! self::$__instance instanceof self ) |
|
| 72 | - self::$__instance = new self; |
|
| 72 | + if ( ! self::$__instance instanceof self ) { |
|
| 73 | + self::$__instance = new self; |
|
| 74 | + } |
|
| 73 | 75 | return self::$__instance; |
| 74 | 76 | } |
| 75 | 77 | |
@@ -92,8 +94,9 @@ discard block |
||
| 92 | 94 | * Stop all further functionality from loading if the WordPress |
| 93 | 95 | * plugin is incompatible with the current environment. |
| 94 | 96 | */ |
| 95 | - if ( ! $this->is_compatible() ) |
|
| 96 | - return; |
|
| 97 | + if ( ! $this->is_compatible() ) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 97 | 100 | |
| 98 | 101 | /** Register hooks that are fired when the plugin is activated and deactivated. */ |
| 99 | 102 | register_activation_hook( $this->dir( 'gravityview.php' ), array( $this, 'activate' ) ); |
@@ -236,8 +239,9 @@ discard block |
||
| 236 | 239 | * @return string The version of Gravity Forms. |
| 237 | 240 | */ |
| 238 | 241 | private function get_gravityforms_version() { |
| 239 | - if ( !class_exists( '\GFCommon' ) || !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) ) |
|
| 240 | - throw new \ErrorException( 'Gravity Forms is inactive or not installed.' ); |
|
| 242 | + if ( !class_exists( '\GFCommon' ) || !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) ) { |
|
| 243 | + throw new \ErrorException( 'Gravity Forms is inactive or not installed.' ); |
|
| 244 | + } |
|
| 241 | 245 | |
| 242 | 246 | return !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] ) ? |
| 243 | 247 | $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] : \GFCommon::$version; |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | 26 | public function append( $value ) { |
| 27 | - $this->storage []= $value; |
|
| 27 | + $this->storage [ ] = $value; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -2,8 +2,9 @@ |
||
| 2 | 2 | namespace GV; |
| 3 | 3 | |
| 4 | 4 | /** If this file is called directly, abort. */ |
| 5 | -if ( ! defined( 'GRAVITYVIEW_DIR' ) ) |
|
| 5 | +if ( ! defined( 'GRAVITYVIEW_DIR' ) ) { |
|
| 6 | 6 | die(); |
| 7 | +} |
|
| 7 | 8 | |
| 8 | 9 | /** |
| 9 | 10 | * A generic Collection base class. |
@@ -2,8 +2,9 @@ |
||
| 2 | 2 | namespace GV; |
| 3 | 3 | |
| 4 | 4 | /** If this file is called directly, abort. */ |
| 5 | -if ( ! defined( 'GRAVITYVIEW_DIR' ) ) |
|
| 5 | +if ( ! defined( 'GRAVITYVIEW_DIR' ) ) { |
|
| 6 | 6 | die(); |
| 7 | +} |
|
| 7 | 8 | |
| 8 | 9 | /** |
| 9 | 10 | * The default Request class. |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | private function __construct( $passed_post = NULL ) { |
| 19 | 19 | |
| 20 | - if( !empty( $passed_post ) ) { |
|
| 20 | + if ( ! empty( $passed_post ) ) { |
|
| 21 | 21 | |
| 22 | 22 | $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
| 23 | 23 | |
| 24 | - if( !empty( $id_or_id_array ) ) { |
|
| 24 | + if ( ! empty( $id_or_id_array ) ) { |
|
| 25 | 25 | $this->add_view( $id_or_id_array ); |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -58,40 +58,40 @@ discard block |
||
| 58 | 58 | public function maybe_get_view_id( $passed_post ) { |
| 59 | 59 | $ids = array(); |
| 60 | 60 | |
| 61 | - if( ! empty( $passed_post ) ) { |
|
| 61 | + if ( ! empty( $passed_post ) ) { |
|
| 62 | 62 | |
| 63 | - if( is_numeric( $passed_post ) ) { |
|
| 63 | + if ( is_numeric( $passed_post ) ) { |
|
| 64 | 64 | $passed_post = get_post( $passed_post ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Convert WP_Posts into WP_Posts[] array |
| 68 | - if( $passed_post instanceof WP_Post ) { |
|
| 68 | + if ( $passed_post instanceof WP_Post ) { |
|
| 69 | 69 | $passed_post = array( $passed_post ); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if( is_array( $passed_post ) ) { |
|
| 72 | + if ( is_array( $passed_post ) ) { |
|
| 73 | 73 | |
| 74 | - foreach ( $passed_post as &$post) { |
|
| 74 | + foreach ( $passed_post as &$post ) { |
|
| 75 | 75 | if ( function_exists( 'gravityview' ) && $post instanceof WP_Post ) { |
| 76 | 76 | $views = \GV\View_Collection::from_post( $post ); |
| 77 | 77 | foreach ( $views->all() as $view ) { |
| 78 | - $ids []= $view->ID; |
|
| 78 | + $ids [ ] = $view->ID; |
|
| 79 | 79 | } |
| 80 | 80 | } else { |
| 81 | 81 | /** Deprecated, see \GV\View_Collection::from_post */ |
| 82 | - if( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
| 83 | - $ids[] = $post->ID; |
|
| 84 | - } else{ |
|
| 82 | + if ( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
| 83 | + $ids[ ] = $post->ID; |
|
| 84 | + } else { |
|
| 85 | 85 | // Parse the Post Content |
| 86 | 86 | $id = $this->parse_post_content( $post->post_content ); |
| 87 | - if( $id ) { |
|
| 88 | - $ids = array_merge( $ids, (array) $id ); |
|
| 87 | + if ( $id ) { |
|
| 88 | + $ids = array_merge( $ids, (array)$id ); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Parse the Post Meta |
| 92 | 92 | $id = $this->parse_post_meta( $post->ID ); |
| 93 | - if( $id ) { |
|
| 94 | - $ids = array_merge( $ids, (array) $id ); |
|
| 93 | + if ( $id ) { |
|
| 94 | + $ids = array_merge( $ids, (array)$id ); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -105,31 +105,31 @@ discard block |
||
| 105 | 105 | if ( function_exists( 'gravityview' ) ) { |
| 106 | 106 | $shortcodes = \GV\Shortcode::parse( $passed_post ); |
| 107 | 107 | foreach ( $shortcodes as $shortcode ) { |
| 108 | - if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) ) |
|
| 109 | - $ids []= $shortcode->atts['id']; |
|
| 108 | + if ( $shortcode->name == 'gravityview' && ! empty( $shortcode->atts[ 'id' ] ) ) |
|
| 109 | + $ids [ ] = $shortcode->atts[ 'id' ]; |
|
| 110 | 110 | } |
| 111 | 111 | } else { |
| 112 | 112 | /** Deprecated, use \GV\Shortcode::parse. */ |
| 113 | 113 | $id = $this->parse_post_content( $passed_post ); |
| 114 | - if( $id ) { |
|
| 115 | - $ids = array_merge( $ids, (array) $id ); |
|
| 114 | + if ( $id ) { |
|
| 115 | + $ids = array_merge( $ids, (array)$id ); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | } else { |
| 120 | 120 | $id = $this->get_id_from_atts( $passed_post ); |
| 121 | - $ids[] = intval( $id ); |
|
| 121 | + $ids[ ] = intval( $id ); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if( empty($ids) ) { |
|
| 126 | + if ( empty( $ids ) ) { |
|
| 127 | 127 | return NULL; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // If it's just one ID, return that. |
| 131 | 131 | // Otherwise, return array of IDs |
| 132 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
| 132 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public static function getInstance( $passed_post = NULL ) { |
| 139 | 139 | |
| 140 | - if( empty( self::$instance ) ) { |
|
| 140 | + if ( empty( self::$instance ) ) { |
|
| 141 | 141 | self::$instance = new GravityView_View_Data( $passed_post ); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -150,19 +150,19 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | function get_view( $view_id, $atts = NULL ) { |
| 152 | 152 | |
| 153 | - if( ! is_numeric( $view_id) ) { |
|
| 154 | - do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); |
|
| 153 | + if ( ! is_numeric( $view_id ) ) { |
|
| 154 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id ) ); |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Backup: the view hasn't been fetched yet. Doing it now. |
| 159 | 159 | if ( ! isset( $this->views[ $view_id ] ) ) { |
| 160 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); |
|
| 160 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] View #%s not set yet.', $view_id ) ); |
|
| 161 | 161 | return $this->add_view( $view_id, $atts ); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if ( empty( $this->views[ $view_id ] ) ) { |
| 165 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); |
|
| 165 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id ) ); |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | function add_view( $view_id, $atts = NULL ) { |
| 194 | 194 | |
| 195 | 195 | // Handle array of IDs |
| 196 | - if( is_array( $view_id ) ) { |
|
| 197 | - foreach( $view_id as $id ) { |
|
| 196 | + if ( is_array( $view_id ) ) { |
|
| 197 | + foreach ( $view_id as $id ) { |
|
| 198 | 198 | |
| 199 | 199 | $this->add_view( $id, $atts ); |
| 200 | 200 | } |
@@ -203,21 +203,21 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // The view has been set already; returning stored view. |
| 206 | - if ( !empty( $this->views[ $view_id ] ) ) { |
|
| 207 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); |
|
| 206 | + if ( ! empty( $this->views[ $view_id ] ) ) { |
|
| 207 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id ) ); |
|
| 208 | 208 | return $this->views[ $view_id ]; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if( ! $this->view_exists( $view_id ) ) { |
|
| 212 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); |
|
| 211 | + if ( ! $this->view_exists( $view_id ) ) { |
|
| 212 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id ) ); |
|
| 213 | 213 | return false; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $form_id = gravityview_get_form_id( $view_id ); |
| 217 | 217 | |
| 218 | - if( empty( $form_id ) ) { |
|
| 218 | + if ( empty( $form_id ) ) { |
|
| 219 | 219 | |
| 220 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); |
|
| 220 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id ) ); |
|
| 221 | 221 | |
| 222 | 222 | return false; |
| 223 | 223 | } |
@@ -225,21 +225,21 @@ discard block |
||
| 225 | 225 | // Get the settings for the View ID |
| 226 | 226 | $view_settings = gravityview_get_template_settings( $view_id ); |
| 227 | 227 | |
| 228 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); |
|
| 228 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id ), $view_settings ); |
|
| 229 | 229 | |
| 230 | 230 | // Merge the view settings with the defaults |
| 231 | 231 | $view_defaults = wp_parse_args( $view_settings, self::get_default_args() ); |
| 232 | 232 | |
| 233 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
| 233 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
| 234 | 234 | |
| 235 | - if( ! empty( $atts ) && is_array( $atts ) ) { |
|
| 235 | + if ( ! empty( $atts ) && is_array( $atts ) ) { |
|
| 236 | 236 | |
| 237 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
| 237 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
| 238 | 238 | |
| 239 | 239 | // Get the settings from the shortcode and merge them with defaults. |
| 240 | 240 | $atts = shortcode_atts( $view_defaults, $atts ); |
| 241 | 241 | |
| 242 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
| 242 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
| 243 | 243 | |
| 244 | 244 | } else { |
| 245 | 245 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - unset( $atts['id'], $view_defaults, $view_settings ); |
|
| 251 | + unset( $atts[ 'id' ], $view_defaults, $view_settings ); |
|
| 252 | 252 | |
| 253 | 253 | $data = array( |
| 254 | 254 | 'id' => $view_id, |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | 'form' => gravityview_get_form( $form_id ), |
| 262 | 262 | ); |
| 263 | 263 | |
| 264 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); |
|
| 264 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] View #%s being added.', $view_id ), $data ); |
|
| 265 | 265 | |
| 266 | 266 | $this->views[ $view_id ] = $data; |
| 267 | 267 | |
@@ -296,15 +296,15 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | private function filter_fields( $dir_fields ) { |
| 298 | 298 | |
| 299 | - if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { |
|
| 299 | + if ( empty( $dir_fields ) || ! is_array( $dir_fields ) ) { |
|
| 300 | 300 | return $dir_fields; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - foreach( $dir_fields as $area => $fields ) { |
|
| 303 | + foreach ( $dir_fields as $area => $fields ) { |
|
| 304 | 304 | |
| 305 | - foreach( (array)$fields as $uniqid => $properties ) { |
|
| 305 | + foreach ( (array)$fields as $uniqid => $properties ) { |
|
| 306 | 306 | |
| 307 | - if( $this->hide_field_check_conditions( $properties ) ) { |
|
| 307 | + if ( $this->hide_field_check_conditions( $properties ) ) { |
|
| 308 | 308 | unset( $dir_fields[ $area ][ $uniqid ] ); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | private function hide_field_check_conditions( $properties ) { |
| 327 | 327 | |
| 328 | 328 | // logged-in visibility |
| 329 | - if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { |
|
| 329 | + if ( ! empty( $properties[ 'only_loggedin' ] ) && ! GVCommon::has_cap( $properties[ 'only_loggedin_cap' ] ) ) { |
|
| 330 | 330 | return true; |
| 331 | 331 | } |
| 332 | 332 | |
@@ -343,14 +343,14 @@ discard block |
||
| 343 | 343 | // Get the settings from the shortcode and merge them with defaults. |
| 344 | 344 | $atts = wp_parse_args( $atts, self::get_default_args() ); |
| 345 | 345 | |
| 346 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; |
|
| 346 | + $view_id = ! empty( $atts[ 'view_id' ] ) ? (int)$atts[ 'view_id' ] : NULL; |
|
| 347 | 347 | |
| 348 | - if( empty( $view_id ) && !empty( $atts['id'] ) ) { |
|
| 349 | - $view_id = (int)$atts['id']; |
|
| 348 | + if ( empty( $view_id ) && ! empty( $atts[ 'id' ] ) ) { |
|
| 349 | + $view_id = (int)$atts[ 'id' ]; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if( empty( $view_id ) ) { |
|
| 353 | - do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
| 352 | + if ( empty( $view_id ) ) { |
|
| 353 | + do_action( 'gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
| 354 | 354 | return; |
| 355 | 355 | } |
| 356 | 356 | |
@@ -372,46 +372,46 @@ discard block |
||
| 372 | 372 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin |
| 373 | 373 | * @since 1.6 |
| 374 | 374 | */ |
| 375 | - if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { |
|
| 375 | + if ( ! shortcode_exists( 'gravityview' ) && class_exists( 'GravityView_Shortcode' ) ) { |
|
| 376 | 376 | new GravityView_Shortcode; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); |
| 380 | 380 | |
| 381 | - if( empty( $shortcodes ) ) { |
|
| 381 | + if ( empty( $shortcodes ) ) { |
|
| 382 | 382 | return NULL; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
| 385 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
| 386 | 386 | |
| 387 | 387 | $ids = array(); |
| 388 | 388 | |
| 389 | - foreach ($shortcodes as $key => $shortcode) { |
|
| 389 | + foreach ( $shortcodes as $key => $shortcode ) { |
|
| 390 | 390 | |
| 391 | - $shortcode[3] = htmlspecialchars_decode( $shortcode[3], ENT_QUOTES ); |
|
| 391 | + $shortcode[ 3 ] = htmlspecialchars_decode( $shortcode[ 3 ], ENT_QUOTES ); |
|
| 392 | 392 | |
| 393 | - $args = shortcode_parse_atts( $shortcode[3] ); |
|
| 393 | + $args = shortcode_parse_atts( $shortcode[ 3 ] ); |
|
| 394 | 394 | |
| 395 | - if( empty( $args['id'] ) ) { |
|
| 396 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
| 395 | + if ( empty( $args[ 'id' ] ) ) { |
|
| 396 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
| 397 | 397 | continue; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); |
|
| 400 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args[ 'id' ] ), $args ); |
|
| 401 | 401 | |
| 402 | 402 | // Store the View to the object for later fetching. |
| 403 | - $this->add_view( $args['id'], $args ); |
|
| 403 | + $this->add_view( $args[ 'id' ], $args ); |
|
| 404 | 404 | |
| 405 | - $ids[] = $args['id']; |
|
| 405 | + $ids[ ] = $args[ 'id' ]; |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if( empty($ids) ) { |
|
| 408 | + if ( empty( $ids ) ) { |
|
| 409 | 409 | return NULL; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | // If it's just one ID, return that. |
| 413 | 413 | // Otherwise, return array of IDs |
| 414 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
| 414 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
| 415 | 415 | |
| 416 | 416 | } |
| 417 | 417 | |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); |
| 434 | 434 | |
| 435 | - if( empty( $meta_keys ) ) { |
|
| 435 | + if ( empty( $meta_keys ) ) { |
|
| 436 | 436 | return NULL; |
| 437 | 437 | } |
| 438 | 438 | |
@@ -440,16 +440,16 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | $meta_content = ''; |
| 442 | 442 | |
| 443 | - foreach( $meta_keys as $key ) { |
|
| 444 | - $meta = get_post_meta( $post_id, $key , true ); |
|
| 445 | - if( ! is_string( $meta ) ) { |
|
| 443 | + foreach ( $meta_keys as $key ) { |
|
| 444 | + $meta = get_post_meta( $post_id, $key, true ); |
|
| 445 | + if ( ! is_string( $meta ) ) { |
|
| 446 | 446 | continue; |
| 447 | 447 | } |
| 448 | 448 | $meta_content .= $meta . ' '; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - if( empty( $meta_content ) ) { |
|
| 452 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
| 451 | + if ( empty( $meta_content ) ) { |
|
| 452 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
| 453 | 453 | return NULL; |
| 454 | 454 | } |
| 455 | 455 | |
@@ -476,16 +476,16 @@ discard block |
||
| 476 | 476 | $message = NULL; |
| 477 | 477 | |
| 478 | 478 | // Not invalid if not set! |
| 479 | - if( empty( $post_id ) || empty( $view_id ) ) { |
|
| 479 | + if ( empty( $post_id ) || empty( $view_id ) ) { |
|
| 480 | 480 | |
| 481 | - if( $empty_is_valid ) { |
|
| 481 | + if ( $empty_is_valid ) { |
|
| 482 | 482 | return true; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | $message = esc_html__( 'The ID is required.', 'gravityview' ); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - if( ! $message ) { |
|
| 488 | + if ( ! $message ) { |
|
| 489 | 489 | $status = get_post_status( $post_id ); |
| 490 | 490 | |
| 491 | 491 | // Nothing exists with that post ID. |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - if( ! $message ) { |
|
| 500 | + if ( ! $message ) { |
|
| 501 | 501 | |
| 502 | 502 | // Nothing exists with that post ID. |
| 503 | 503 | if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { |
@@ -506,8 +506,8 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - if( ! $message ) { |
|
| 510 | - if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
|
| 509 | + if ( ! $message ) { |
|
| 510 | + if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
|
| 511 | 511 | $views = GV\View_Collection::from_post( $post ); |
| 512 | 512 | $view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() ); |
| 513 | 513 | } else { |
@@ -516,21 +516,21 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // The post or page specified does not contain the shortcode. |
| 519 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
| 519 | + if ( false === in_array( $view_id, (array)$view_ids_in_post ) ) { |
|
| 520 | 520 | $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); |
| 521 | 521 | } |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | - if( ! $message ) { |
|
| 524 | + if ( ! $message ) { |
|
| 525 | 525 | |
| 526 | 526 | // It's a View |
| 527 | - if( 'gravityview' === get_post_type( $post_id ) ) { |
|
| 528 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
| 527 | + if ( 'gravityview' === get_post_type( $post_id ) ) { |
|
| 528 | + $message = esc_html__( 'The ID is already a View.', 'gravityview' ); ; |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - if( $message ) { |
|
| 533 | + if ( $message ) { |
|
| 534 | 534 | return new WP_Error( 'invalid_embed_id', $message ); |
| 535 | 535 | } |
| 536 | 536 | |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | $args = self::get_default_args( $with_details ); |
| 549 | 549 | |
| 550 | - if( !isset( $args[ $key ] ) ) { return NULL; } |
|
| 550 | + if ( ! isset( $args[ $key ] ) ) { return NULL; } |
|
| 551 | 551 | |
| 552 | 552 | return $args[ $key ]; |
| 553 | 553 | } |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | */ |
| 577 | 577 | $default_settings = apply_filters( 'gravityview_default_args', array( |
| 578 | 578 | 'id' => array( |
| 579 | - 'label' => __('View ID', 'gravityview'), |
|
| 579 | + 'label' => __( 'View ID', 'gravityview' ), |
|
| 580 | 580 | 'type' => 'number', |
| 581 | 581 | 'group' => 'default', |
| 582 | 582 | 'value' => NULL, |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | 'show_in_shortcode' => false, |
| 585 | 585 | ), |
| 586 | 586 | 'page_size' => array( |
| 587 | - 'label' => __('Number of entries per page', 'gravityview'), |
|
| 587 | + 'label' => __( 'Number of entries per page', 'gravityview' ), |
|
| 588 | 588 | 'type' => 'number', |
| 589 | 589 | 'class' => 'small-text', |
| 590 | 590 | 'group' => 'default', |
@@ -608,8 +608,8 @@ discard block |
||
| 608 | 608 | ), |
| 609 | 609 | 'admin_show_all_statuses' => array( |
| 610 | 610 | 'label' => __( 'Show all entries to administrators', 'gravityview' ), |
| 611 | - 'desc' => __('Administrators will be able to see entries with any approval status.', 'gravityview'), |
|
| 612 | - 'tooltip' => __('Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview'), |
|
| 611 | + 'desc' => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ), |
|
| 612 | + 'tooltip' => __( 'Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview' ), |
|
| 613 | 613 | 'requires' => 'show_only_approved', |
| 614 | 614 | 'type' => 'checkbox', |
| 615 | 615 | 'group' => 'default', |
@@ -634,40 +634,40 @@ discard block |
||
| 634 | 634 | 'user_edit' => array( |
| 635 | 635 | 'label' => __( 'Allow User Edit', 'gravityview' ), |
| 636 | 636 | 'group' => 'default', |
| 637 | - 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
|
| 637 | + 'desc' => __( 'Allow logged-in users to edit entries they created.', 'gravityview' ), |
|
| 638 | 638 | 'value' => 0, |
| 639 | - 'tooltip' => __('Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
| 639 | + 'tooltip' => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
| 640 | 640 | 'type' => 'checkbox', |
| 641 | 641 | 'show_in_shortcode' => true, |
| 642 | 642 | ), |
| 643 | 643 | 'user_delete' => array( |
| 644 | 644 | 'label' => __( 'Allow User Delete', 'gravityview' ), |
| 645 | 645 | 'group' => 'default', |
| 646 | - 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
|
| 646 | + 'desc' => __( 'Allow logged-in users to delete entries they created.', 'gravityview' ), |
|
| 647 | 647 | 'value' => 0, |
| 648 | - 'tooltip' => __('Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
| 648 | + 'tooltip' => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
| 649 | 649 | 'type' => 'checkbox', |
| 650 | 650 | 'show_in_shortcode' => true, |
| 651 | 651 | ), |
| 652 | 652 | 'sort_field' => array( |
| 653 | - 'label' => __('Sort by field', 'gravityview'), |
|
| 653 | + 'label' => __( 'Sort by field', 'gravityview' ), |
|
| 654 | 654 | 'type' => 'select', |
| 655 | 655 | 'value' => '', |
| 656 | 656 | 'group' => 'sort', |
| 657 | 657 | 'options' => array( |
| 658 | - '' => __( 'Default', 'gravityview'), |
|
| 659 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
| 658 | + '' => __( 'Default', 'gravityview' ), |
|
| 659 | + 'date_created' => __( 'Date Created', 'gravityview' ), |
|
| 660 | 660 | ), |
| 661 | 661 | 'show_in_shortcode' => true, |
| 662 | 662 | ), |
| 663 | 663 | 'sort_direction' => array( |
| 664 | - 'label' => __('Sort direction', 'gravityview'), |
|
| 664 | + 'label' => __( 'Sort direction', 'gravityview' ), |
|
| 665 | 665 | 'type' => 'select', |
| 666 | 666 | 'value' => 'ASC', |
| 667 | 667 | 'group' => 'sort', |
| 668 | 668 | 'options' => array( |
| 669 | - 'ASC' => __('ASC', 'gravityview'), |
|
| 670 | - 'DESC' => __('DESC', 'gravityview'), |
|
| 669 | + 'ASC' => __( 'ASC', 'gravityview' ), |
|
| 670 | + 'DESC' => __( 'DESC', 'gravityview' ), |
|
| 671 | 671 | //'RAND' => __('Random', 'gravityview'), |
| 672 | 672 | ), |
| 673 | 673 | 'show_in_shortcode' => true, |
@@ -683,69 +683,69 @@ discard block |
||
| 683 | 683 | 'show_in_template' => array( 'default_table' ), |
| 684 | 684 | ), |
| 685 | 685 | 'start_date' => array( |
| 686 | - 'label' => __('Filter by Start Date', 'gravityview'), |
|
| 686 | + 'label' => __( 'Filter by Start Date', 'gravityview' ), |
|
| 687 | 687 | 'class' => 'gv-datepicker', |
| 688 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
| 688 | + 'desc' => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
| 689 | 689 | 'type' => 'text', |
| 690 | 690 | 'value' => '', |
| 691 | 691 | 'group' => 'filter', |
| 692 | 692 | 'show_in_shortcode' => true, |
| 693 | 693 | ), |
| 694 | 694 | 'end_date' => array( |
| 695 | - 'label' => __('Filter by End Date', 'gravityview'), |
|
| 695 | + 'label' => __( 'Filter by End Date', 'gravityview' ), |
|
| 696 | 696 | 'class' => 'gv-datepicker', |
| 697 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
| 697 | + 'desc' => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
| 698 | 698 | 'type' => 'text', |
| 699 | 699 | 'value' => '', |
| 700 | 700 | 'group' => 'filter', |
| 701 | 701 | 'show_in_shortcode' => true, |
| 702 | 702 | ), |
| 703 | 703 | 'class' => array( |
| 704 | - 'label' => __('CSS Class', 'gravityview'), |
|
| 705 | - 'desc' => __('CSS class to add to the wrapping HTML container.', 'gravityview'), |
|
| 704 | + 'label' => __( 'CSS Class', 'gravityview' ), |
|
| 705 | + 'desc' => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ), |
|
| 706 | 706 | 'group' => 'default', |
| 707 | 707 | 'type' => 'text', |
| 708 | 708 | 'value' => '', |
| 709 | 709 | 'show_in_shortcode' => false, |
| 710 | 710 | ), |
| 711 | 711 | 'search_value' => array( |
| 712 | - 'label' => __('Search Value', 'gravityview'), |
|
| 713 | - 'desc' => __('Define a default search value for the View', 'gravityview'), |
|
| 712 | + 'label' => __( 'Search Value', 'gravityview' ), |
|
| 713 | + 'desc' => __( 'Define a default search value for the View', 'gravityview' ), |
|
| 714 | 714 | 'type' => 'text', |
| 715 | 715 | 'value' => '', |
| 716 | 716 | 'group' => 'filter', |
| 717 | 717 | 'show_in_shortcode' => false, |
| 718 | 718 | ), |
| 719 | 719 | 'search_field' => array( |
| 720 | - 'label' => __('Search Field', 'gravityview'), |
|
| 721 | - 'desc' => __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'), |
|
| 720 | + 'label' => __( 'Search Field', 'gravityview' ), |
|
| 721 | + 'desc' => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ), |
|
| 722 | 722 | 'type' => 'number', |
| 723 | 723 | 'value' => '', |
| 724 | 724 | 'group' => 'filter', |
| 725 | 725 | 'show_in_shortcode' => false, |
| 726 | 726 | ), |
| 727 | 727 | 'single_title' => array( |
| 728 | - 'label' => __('Single Entry Title', 'gravityview'), |
|
| 728 | + 'label' => __( 'Single Entry Title', 'gravityview' ), |
|
| 729 | 729 | 'type' => 'text', |
| 730 | - 'desc' => __('When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview'), |
|
| 730 | + 'desc' => __( 'When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview' ), |
|
| 731 | 731 | 'group' => 'default', |
| 732 | 732 | 'value' => '', |
| 733 | 733 | 'show_in_shortcode' => false, |
| 734 | 734 | 'full_width' => true, |
| 735 | 735 | ), |
| 736 | 736 | 'back_link_label' => array( |
| 737 | - 'label' => __('Back Link Label', 'gravityview'), |
|
| 737 | + 'label' => __( 'Back Link Label', 'gravityview' ), |
|
| 738 | 738 | 'group' => 'default', |
| 739 | - 'desc' => __('The text of the link that returns to the multiple entries view.', 'gravityview'), |
|
| 739 | + 'desc' => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ), |
|
| 740 | 740 | 'type' => 'text', |
| 741 | 741 | 'value' => '', |
| 742 | 742 | 'show_in_shortcode' => false, |
| 743 | 743 | 'full_width' => true, |
| 744 | 744 | ), |
| 745 | 745 | 'embed_only' => array( |
| 746 | - 'label' => __('Prevent Direct Access', 'gravityview'), |
|
| 746 | + 'label' => __( 'Prevent Direct Access', 'gravityview' ), |
|
| 747 | 747 | 'group' => 'default', |
| 748 | - 'desc' => __('Only allow access to this View when embedded using the shortcode.', 'gravityview'), |
|
| 748 | + 'desc' => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ), |
|
| 749 | 749 | 'type' => 'checkbox', |
| 750 | 750 | 'value' => '', |
| 751 | 751 | 'show_in_shortcode' => false, |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | 'value' => '', |
| 757 | 757 | 'show_in_shortcode' => false, |
| 758 | 758 | ), |
| 759 | - )); |
|
| 759 | + ) ); |
|
| 760 | 760 | |
| 761 | 761 | // By default, we only want the key => value pairing, not the whole array. |
| 762 | - if( empty( $with_details ) ) { |
|
| 762 | + if ( empty( $with_details ) ) { |
|
| 763 | 763 | |
| 764 | 764 | $defaults = array(); |
| 765 | 765 | |
| 766 | - foreach( $default_settings as $key => $value ) { |
|
| 767 | - $defaults[ $key ] = $value['value']; |
|
| 766 | + foreach ( $default_settings as $key => $value ) { |
|
| 767 | + $defaults[ $key ] = $value[ 'value' ]; |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | return $defaults; |
@@ -773,12 +773,12 @@ discard block |
||
| 773 | 773 | // But sometimes, we want all the details. |
| 774 | 774 | else { |
| 775 | 775 | |
| 776 | - foreach ($default_settings as $key => $value) { |
|
| 776 | + foreach ( $default_settings as $key => $value ) { |
|
| 777 | 777 | |
| 778 | 778 | // If the $group argument is set for the method, |
| 779 | 779 | // ignore any settings that aren't in that group. |
| 780 | - if( !empty( $group ) && is_string( $group ) ) { |
|
| 781 | - if( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
| 780 | + if ( ! empty( $group ) && is_string( $group ) ) { |
|
| 781 | + if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) { |
|
| 782 | 782 | unset( $default_settings[ $key ] ); |
| 783 | 783 | } |
| 784 | 784 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** Deprecated, see \GV\View_Collection::from_post */ |
| 82 | 82 | if( ( get_post_type( $post ) === 'gravityview' ) ) { |
| 83 | 83 | $ids[] = $post->ID; |
| 84 | - } else{ |
|
| 84 | + } else { |
|
| 85 | 85 | // Parse the Post Content |
| 86 | 86 | $id = $this->parse_post_content( $post->post_content ); |
| 87 | 87 | if( $id ) { |
@@ -105,8 +105,9 @@ discard block |
||
| 105 | 105 | if ( function_exists( 'gravityview' ) ) { |
| 106 | 106 | $shortcodes = \GV\Shortcode::parse( $passed_post ); |
| 107 | 107 | foreach ( $shortcodes as $shortcode ) { |
| 108 | - if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) ) |
|
| 109 | - $ids []= $shortcode->atts['id']; |
|
| 108 | + if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) ) { |
|
| 109 | + $ids []= $shortcode->atts['id']; |
|
| 110 | + } |
|
| 110 | 111 | } |
| 111 | 112 | } else { |
| 112 | 113 | /** Deprecated, use \GV\Shortcode::parse. */ |
@@ -507,7 +508,7 @@ discard block |
||
| 507 | 508 | } |
| 508 | 509 | |
| 509 | 510 | if( ! $message ) { |
| 510 | - if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
|
| 511 | + if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
|
| 511 | 512 | $views = GV\View_Collection::from_post( $post ); |
| 512 | 513 | $view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() ); |
| 513 | 514 | } else { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | static function getInstance() { |
| 44 | 44 | |
| 45 | - if( empty( self::$instance ) ) { |
|
| 45 | + if ( empty( self::$instance ) ) { |
|
| 46 | 46 | self::$instance = new self; |
| 47 | 47 | |
| 48 | 48 | self::$instance->initialize(); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | // Catch either |
| 100 | 100 | $match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; |
| 101 | 101 | |
| 102 | - return '#'.$match_regex.'#i'; |
|
| 102 | + return '#' . $match_regex . '#i'; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -118,18 +118,18 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $post_id = url_to_postid( $url ); |
| 120 | 120 | |
| 121 | - if( empty( $post_id ) ) { |
|
| 121 | + if ( empty( $post_id ) ) { |
|
| 122 | 122 | |
| 123 | 123 | $args = array( |
| 124 | 124 | 'post_status' => 'publish', |
| 125 | 125 | 'name' => $slug, |
| 126 | - 'post_type' => array('any', 'gravityview'), |
|
| 126 | + 'post_type' => array( 'any', 'gravityview' ), |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | $posts = get_posts( $args ); |
| 130 | 130 | |
| 131 | - if( !empty( $posts ) ) { |
|
| 132 | - $post_id = $posts[0]->ID; |
|
| 131 | + if ( ! empty( $posts ) ) { |
|
| 132 | + $post_id = $posts[ 0 ]->ID; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -162,17 +162,17 @@ discard block |
||
| 162 | 162 | public function render_handler( $matches, $attr, $url, $rawattr ) { |
| 163 | 163 | |
| 164 | 164 | // If not using permalinks, re-assign values for matching groups |
| 165 | - if( !empty( $matches['entry_slug2'] ) ) { |
|
| 166 | - $matches['is_cpt'] = $matches['is_cpt2']; |
|
| 167 | - $matches['slug'] = $matches['slug2']; |
|
| 168 | - $matches['entry_slug'] = $matches['entry_slug2']; |
|
| 169 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
| 165 | + if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
| 166 | + $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
| 167 | + $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
| 168 | + $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
| 169 | + unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // No Entry was found |
| 173 | - if( empty( $matches['entry_slug'] ) ) { |
|
| 173 | + if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
| 174 | 174 | |
| 175 | - do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
| 175 | + do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
| 176 | 176 | |
| 177 | 177 | return ''; |
| 178 | 178 | } |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | // Setup the data used |
| 183 | 183 | $this->set_vars( $matches, $attr, $url, $rawattr ); |
| 184 | 184 | |
| 185 | - if( is_admin() && !$this->is_full_oembed_preview ) { |
|
| 185 | + if ( is_admin() && ! $this->is_full_oembed_preview ) { |
|
| 186 | 186 | $return = $this->render_admin( $matches, $attr, $url, $rawattr ); |
| 187 | 187 | } else { |
| 188 | 188 | |
| 189 | - if( $this->is_full_oembed_preview ) { |
|
| 189 | + if ( $this->is_full_oembed_preview ) { |
|
| 190 | 190 | $return .= $this->generate_preview_notice(); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | private function generate_preview_notice() { |
| 206 | 206 | $floaty = GravityView_Admin::get_floaty(); |
| 207 | 207 | $title = esc_html__( 'This will look better when it is embedded.', 'gravityview' ); |
| 208 | - $message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview'); |
|
| 209 | - return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
| 208 | + $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' ); |
|
| 209 | + return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>'; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -219,20 +219,20 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | private function set_vars( $matches, $attr, $url, $rawattr ) { |
| 221 | 221 | |
| 222 | - $this->entry_id = $matches['entry_slug']; |
|
| 222 | + $this->entry_id = $matches[ 'entry_slug' ]; |
|
| 223 | 223 | |
| 224 | - $post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] ); |
|
| 224 | + $post_id = $this->get_postid_from_url_and_slug( $url, $matches[ 'slug' ] ); |
|
| 225 | 225 | |
| 226 | 226 | // The URL didn't have the View Custom Post Type structure. |
| 227 | - if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) { |
|
| 227 | + if ( empty( $matches[ 'is_cpt' ] ) || $matches[ 'is_cpt' ] !== 'gravityview' ) { |
|
| 228 | 228 | |
| 229 | - do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
| 229 | + do_action( 'gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
| 230 | 230 | |
| 231 | 231 | if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
| 232 | 232 | $views = \GV\View_Collection::from_post( $post ); |
| 233 | 233 | $views = $views->all(); |
| 234 | 234 | if ( ! empty( $views ) ) |
| 235 | - $this->view_id = $views[0]->ID; |
|
| 235 | + $this->view_id = $views[ 0 ]->ID; |
|
| 236 | 236 | } else { |
| 237 | 237 | /** Deprecated. */ |
| 238 | 238 | $this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that. |
| 248 | - $this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) ); |
|
| 248 | + $this->is_full_oembed_preview = ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'parse-embed' && ! isset( $_POST[ 'type' ] ) ); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -263,15 +263,15 @@ discard block |
||
| 263 | 263 | // Floaty the astronaut |
| 264 | 264 | $image = GravityView_Admin::get_floaty(); |
| 265 | 265 | |
| 266 | - $embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id ); |
|
| 266 | + $embed_heading = sprintf( esc_html__( 'Embed Entry %d', 'gravityview' ), $this->entry_id ); |
|
| 267 | 267 | |
| 268 | - $embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id ); |
|
| 268 | + $embed_text = sprintf( esc_html__( 'This entry will be displayed as it is configured in View %d', 'gravityview' ), $this->view_id ); |
|
| 269 | 269 | |
| 270 | 270 | return ' |
| 271 | 271 | <div class="loading-placeholder" style="background-color:#e6f0f5;"> |
| 272 | - <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3> |
|
| 272 | + <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3> |
|
| 273 | 273 | <p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;"> |
| 274 | - '.$embed_text.' |
|
| 274 | + '.$embed_text . ' |
|
| 275 | 275 | </p> |
| 276 | 276 | <br style="clear: both;"> |
| 277 | 277 | </div>'; |
@@ -326,14 +326,14 @@ discard block |
||
| 326 | 326 | private function render_frontend( $matches, $attr, $url, $rawattr ) { |
| 327 | 327 | |
| 328 | 328 | // If it's already been parsed, don't re-output it. |
| 329 | - if( !empty( $this->output[ $this->entry_id ] ) ) { |
|
| 329 | + if ( ! empty( $this->output[ $this->entry_id ] ) ) { |
|
| 330 | 330 | return $this->output[ $this->entry_id ]; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | $entry_output = $this->generate_entry_output(); |
| 334 | 334 | |
| 335 | 335 | // Wrap a container div around the output to allow for custom styling |
| 336 | - $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output ); |
|
| 336 | + $output = sprintf( '<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $this->entry_id . '">%s</div>', $entry_output ); |
|
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | 339 | * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @var string $url The original URL that was matched by the regex. \n |
| 347 | 347 | * @var array $rawattr The original unmodified attributes. |
| 348 | 348 | */ |
| 349 | - $output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
| 349 | + $output = apply_filters( 'gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
| 350 | 350 | |
| 351 | 351 | unset( $entry_output ); |
| 352 | 352 | |
@@ -231,8 +231,9 @@ |
||
| 231 | 231 | if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
| 232 | 232 | $views = \GV\View_Collection::from_post( $post ); |
| 233 | 233 | $views = $views->all(); |
| 234 | - if ( ! empty( $views ) ) |
|
| 235 | - $this->view_id = $views[0]->ID; |
|
| 234 | + if ( ! empty( $views ) ) { |
|
| 235 | + $this->view_id = $views[0]->ID; |
|
| 236 | + } |
|
| 236 | 237 | } else { |
| 237 | 238 | /** Deprecated. */ |
| 238 | 239 | $this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
@@ -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,102 +22,102 @@ 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 | - } |
|
| 117 | + remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 118 | + remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 119 | + |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * Get the User Registration feed configuration for the entry & form |
@@ -132,185 +132,185 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return array |
| 134 | 134 | */ |
| 135 | - public function get_feed_configuration( $entry, $form ) { |
|
| 136 | - |
|
| 137 | - /** @var GF_User_Registration $gf_user_registration */ |
|
| 138 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 139 | - |
|
| 140 | - $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
| 144 | - * @since 1.15 |
|
| 145 | - * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
| 146 | - * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
| 147 | - * @param[in] array $form Gravity Forms form array |
|
| 148 | - * @param[in] array $entry Gravity Forms entry being edited |
|
| 149 | - */ |
|
| 150 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
| 151 | - |
|
| 152 | - if( $preserve_role ) { |
|
| 153 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * Make sure the current display name is not changed with the update user method. |
|
| 160 | - * @since 1.15 |
|
| 161 | - */ |
|
| 162 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
| 166 | - * @since 1.14 |
|
| 167 | - * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
| 168 | - * @param[in] array $form Gravity Forms form array |
|
| 169 | - * @param[in] array $entry Gravity Forms entry being edited |
|
| 170 | - */ |
|
| 171 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
| 172 | - |
|
| 173 | - return $config; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Calculate the user display name format |
|
| 178 | - * |
|
| 179 | - * @since 1.15 |
|
| 180 | - * @since 1.20 Returns false if user not found at $user_id |
|
| 181 | - * |
|
| 182 | - * @param int $user_id WP User ID |
|
| 183 | - * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
| 184 | - */ |
|
| 185 | - public function match_current_display_name( $user_id ) { |
|
| 186 | - |
|
| 187 | - $user = get_userdata( $user_id ); |
|
| 188 | - |
|
| 189 | - if( ! $user ) { |
|
| 190 | - return false; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - $names = $this->generate_display_names( $user ); |
|
| 194 | - |
|
| 195 | - $format = array_search( $user->display_name, $names, true ); |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
| 199 | - * @see restore_display_name |
|
| 200 | - */ |
|
| 201 | - if( false === $format ) { |
|
| 202 | - $this->_user_before_update = $user; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - return $format; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Generate an array of all the user display names possibilities |
|
| 210 | - * |
|
| 211 | - * @since 1.15 |
|
| 212 | - * |
|
| 213 | - * @param object $profileuser WP_User object |
|
| 214 | - * @return array List all the possible display names for a certain User object |
|
| 215 | - */ |
|
| 216 | - public function generate_display_names( $profileuser ) { |
|
| 217 | - |
|
| 218 | - $public_display = array(); |
|
| 219 | - $public_display['nickname'] = $profileuser->nickname; |
|
| 220 | - $public_display['username'] = $profileuser->user_login; |
|
| 221 | - |
|
| 222 | - if ( !empty($profileuser->first_name) ) { |
|
| 223 | - $public_display['firstname'] = $profileuser->first_name; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - if ( !empty($profileuser->last_name) ) { |
|
| 227 | - $public_display['lastname'] = $profileuser->last_name; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 231 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 232 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - $public_display = array_map( 'trim', $public_display ); |
|
| 236 | - $public_display = array_unique( $public_display ); |
|
| 237 | - |
|
| 238 | - return $public_display; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
| 244 | - * |
|
| 245 | - * @see GFUser::update_user() |
|
| 246 | - * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
| 247 | - * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
| 248 | - * @param array $entry The Gravity Forms entry that was just updated |
|
| 249 | - * @param string $password User password |
|
| 250 | - * @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 |
|
| 251 | - */ |
|
| 252 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
| 256 | - * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
| 257 | - * @since 1.14.4 |
|
| 258 | - * @param boolean $restore_display_name Restore Display Name? Default: true |
|
| 259 | - */ |
|
| 260 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
| 261 | - |
|
| 262 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * Don't restore display name: |
|
| 266 | - * - either disabled, |
|
| 267 | - * - or it is an Update feed (we only care about Create feed) |
|
| 268 | - * - or we don't need as we found the correct format before updating user. |
|
| 269 | - * @since 1.14.4 |
|
| 270 | - */ |
|
| 271 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 272 | - return null; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - $user_after_update = get_userdata( $user_id ); |
|
| 276 | - |
|
| 277 | - // User not found |
|
| 278 | - if ( ! $user_after_update ) { |
|
| 279 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - $restored_user = $user_after_update; |
|
| 284 | - |
|
| 285 | - // Restore previous display_name |
|
| 286 | - $restored_user->display_name = $this->_user_before_update->display_name; |
|
| 287 | - |
|
| 288 | - // Don't have WP update the password. |
|
| 289 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
| 293 | - * @since 1.14 |
|
| 294 | - * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
| 295 | - * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
| 296 | - * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
| 297 | - * @param array $entry The Gravity Forms entry that was just updated |
|
| 298 | - */ |
|
| 299 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
| 300 | - |
|
| 301 | - $updated = wp_update_user( $restored_user ); |
|
| 302 | - |
|
| 303 | - if( is_wp_error( $updated ) ) { |
|
| 304 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 305 | - } else { |
|
| 306 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - $this->_user_before_update = null; |
|
| 310 | - |
|
| 311 | - unset( $restored_user, $user_after_update ); |
|
| 312 | - |
|
| 313 | - return $updated; |
|
| 314 | - } |
|
| 135 | + public function get_feed_configuration( $entry, $form ) { |
|
| 136 | + |
|
| 137 | + /** @var GF_User_Registration $gf_user_registration */ |
|
| 138 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 139 | + |
|
| 140 | + $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
| 144 | + * @since 1.15 |
|
| 145 | + * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
| 146 | + * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
| 147 | + * @param[in] array $form Gravity Forms form array |
|
| 148 | + * @param[in] array $entry Gravity Forms entry being edited |
|
| 149 | + */ |
|
| 150 | + $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
| 151 | + |
|
| 152 | + if( $preserve_role ) { |
|
| 153 | + $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * Make sure the current display name is not changed with the update user method. |
|
| 160 | + * @since 1.15 |
|
| 161 | + */ |
|
| 162 | + $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
| 166 | + * @since 1.14 |
|
| 167 | + * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
| 168 | + * @param[in] array $form Gravity Forms form array |
|
| 169 | + * @param[in] array $entry Gravity Forms entry being edited |
|
| 170 | + */ |
|
| 171 | + $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
| 172 | + |
|
| 173 | + return $config; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Calculate the user display name format |
|
| 178 | + * |
|
| 179 | + * @since 1.15 |
|
| 180 | + * @since 1.20 Returns false if user not found at $user_id |
|
| 181 | + * |
|
| 182 | + * @param int $user_id WP User ID |
|
| 183 | + * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
| 184 | + */ |
|
| 185 | + public function match_current_display_name( $user_id ) { |
|
| 186 | + |
|
| 187 | + $user = get_userdata( $user_id ); |
|
| 188 | + |
|
| 189 | + if( ! $user ) { |
|
| 190 | + return false; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + $names = $this->generate_display_names( $user ); |
|
| 194 | + |
|
| 195 | + $format = array_search( $user->display_name, $names, true ); |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
| 199 | + * @see restore_display_name |
|
| 200 | + */ |
|
| 201 | + if( false === $format ) { |
|
| 202 | + $this->_user_before_update = $user; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + return $format; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Generate an array of all the user display names possibilities |
|
| 210 | + * |
|
| 211 | + * @since 1.15 |
|
| 212 | + * |
|
| 213 | + * @param object $profileuser WP_User object |
|
| 214 | + * @return array List all the possible display names for a certain User object |
|
| 215 | + */ |
|
| 216 | + public function generate_display_names( $profileuser ) { |
|
| 217 | + |
|
| 218 | + $public_display = array(); |
|
| 219 | + $public_display['nickname'] = $profileuser->nickname; |
|
| 220 | + $public_display['username'] = $profileuser->user_login; |
|
| 221 | + |
|
| 222 | + if ( !empty($profileuser->first_name) ) { |
|
| 223 | + $public_display['firstname'] = $profileuser->first_name; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + if ( !empty($profileuser->last_name) ) { |
|
| 227 | + $public_display['lastname'] = $profileuser->last_name; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 231 | + $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 232 | + $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + $public_display = array_map( 'trim', $public_display ); |
|
| 236 | + $public_display = array_unique( $public_display ); |
|
| 237 | + |
|
| 238 | + return $public_display; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
| 244 | + * |
|
| 245 | + * @see GFUser::update_user() |
|
| 246 | + * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
| 247 | + * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
| 248 | + * @param array $entry The Gravity Forms entry that was just updated |
|
| 249 | + * @param string $password User password |
|
| 250 | + * @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 |
|
| 251 | + */ |
|
| 252 | + public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
| 256 | + * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
| 257 | + * @since 1.14.4 |
|
| 258 | + * @param boolean $restore_display_name Restore Display Name? Default: true |
|
| 259 | + */ |
|
| 260 | + $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
| 261 | + |
|
| 262 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * Don't restore display name: |
|
| 266 | + * - either disabled, |
|
| 267 | + * - or it is an Update feed (we only care about Create feed) |
|
| 268 | + * - or we don't need as we found the correct format before updating user. |
|
| 269 | + * @since 1.14.4 |
|
| 270 | + */ |
|
| 271 | + if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 272 | + return null; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + $user_after_update = get_userdata( $user_id ); |
|
| 276 | + |
|
| 277 | + // User not found |
|
| 278 | + if ( ! $user_after_update ) { |
|
| 279 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + $restored_user = $user_after_update; |
|
| 284 | + |
|
| 285 | + // Restore previous display_name |
|
| 286 | + $restored_user->display_name = $this->_user_before_update->display_name; |
|
| 287 | + |
|
| 288 | + // Don't have WP update the password. |
|
| 289 | + unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
| 293 | + * @since 1.14 |
|
| 294 | + * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
| 295 | + * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
| 296 | + * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
| 297 | + * @param array $entry The Gravity Forms entry that was just updated |
|
| 298 | + */ |
|
| 299 | + $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
| 300 | + |
|
| 301 | + $updated = wp_update_user( $restored_user ); |
|
| 302 | + |
|
| 303 | + if( is_wp_error( $updated ) ) { |
|
| 304 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 305 | + } else { |
|
| 306 | + do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + $this->_user_before_update = null; |
|
| 310 | + |
|
| 311 | + unset( $restored_user, $user_after_update ); |
|
| 312 | + |
|
| 313 | + return $updated; |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | 316 | } //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 | } |
@@ -149,17 +149,17 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
| 151 | 151 | |
| 152 | - if( $preserve_role ) { |
|
| 153 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 152 | + if ( $preserve_role ) { |
|
| 153 | + $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role'; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
| 156 | + $displayname = $this->match_current_display_name( $entry[ 'created_by' ] ); |
|
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * Make sure the current display name is not changed with the update user method. |
| 160 | 160 | * @since 1.15 |
| 161 | 161 | */ |
| 162 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
| 162 | + $config[ 'meta' ][ 'displayname' ] = $displayname ? $displayname : $config[ 'meta' ][ 'displayname' ]; |
|
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | $user = get_userdata( $user_id ); |
| 188 | 188 | |
| 189 | - if( ! $user ) { |
|
| 189 | + if ( ! $user ) { |
|
| 190 | 190 | return false; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
| 199 | 199 | * @see restore_display_name |
| 200 | 200 | */ |
| 201 | - if( false === $format ) { |
|
| 201 | + if ( false === $format ) { |
|
| 202 | 202 | $this->_user_before_update = $user; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -216,20 +216,20 @@ discard block |
||
| 216 | 216 | public function generate_display_names( $profileuser ) { |
| 217 | 217 | |
| 218 | 218 | $public_display = array(); |
| 219 | - $public_display['nickname'] = $profileuser->nickname; |
|
| 220 | - $public_display['username'] = $profileuser->user_login; |
|
| 219 | + $public_display[ 'nickname' ] = $profileuser->nickname; |
|
| 220 | + $public_display[ 'username' ] = $profileuser->user_login; |
|
| 221 | 221 | |
| 222 | - if ( !empty($profileuser->first_name) ) { |
|
| 223 | - $public_display['firstname'] = $profileuser->first_name; |
|
| 222 | + if ( ! empty( $profileuser->first_name ) ) { |
|
| 223 | + $public_display[ 'firstname' ] = $profileuser->first_name; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( !empty($profileuser->last_name) ) { |
|
| 227 | - $public_display['lastname'] = $profileuser->last_name; |
|
| 226 | + if ( ! empty( $profileuser->last_name ) ) { |
|
| 227 | + $public_display[ 'lastname' ] = $profileuser->last_name; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 231 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 232 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 230 | + if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) { |
|
| 231 | + $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 232 | + $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | $public_display = array_map( 'trim', $public_display ); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
| 261 | 261 | |
| 262 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 262 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' ); |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Don't restore display name: |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * - or we don't need as we found the correct format before updating user. |
| 269 | 269 | * @since 1.14.4 |
| 270 | 270 | */ |
| 271 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 271 | + if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 272 | 272 | return null; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | // User not found |
| 278 | 278 | if ( ! $user_after_update ) { |
| 279 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
| 279 | + do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
| 280 | 280 | return false; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -300,10 +300,10 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | $updated = wp_update_user( $restored_user ); |
| 302 | 302 | |
| 303 | - if( is_wp_error( $updated ) ) { |
|
| 304 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 303 | + if ( is_wp_error( $updated ) ) { |
|
| 304 | + do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 305 | 305 | } else { |
| 306 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 306 | + do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $this->_user_before_update = null; |