@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * Return array of fields' id and label, for a given Form ID |
| 218 | 218 | * |
| 219 | 219 | * @access public |
| 220 | - * @param string|array $form_id (default: '') or $form object |
|
| 220 | + * @param string|array $form (default: '') or $form object |
|
| 221 | 221 | * @param bool $add_default_properties |
| 222 | 222 | * @param bool $include_parent_field |
| 223 | 223 | * @return array |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @param array $form Gravity Forms form array |
| 884 | 884 | * @param string $field_id ID of the field. If an input, full input ID (like `1.3`) |
| 885 | - * @param string|array $field_value Raw value of the field. |
|
| 885 | + * @param string $field_value Raw value of the field. |
|
| 886 | 886 | * @return string |
| 887 | 887 | */ |
| 888 | 888 | public static function get_field_label( $form = array(), $field_id = '', $field_value = '' ) { |
@@ -1514,6 +1514,7 @@ discard block |
||
| 1514 | 1514 | * @param string $notice text/HTML of notice |
| 1515 | 1515 | * @param string $class CSS class for notice (`updated` or `error`) |
| 1516 | 1516 | * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
| 1517 | + * @param integer $object_id |
|
| 1517 | 1518 | * |
| 1518 | 1519 | * @return string |
| 1519 | 1520 | */ |
@@ -1557,9 +1558,9 @@ discard block |
||
| 1557 | 1558 | * @param string $message Message body (required) |
| 1558 | 1559 | * @param string $from_name Displayed name of the sender |
| 1559 | 1560 | * @param string $message_format If "html", sent text as `text/html`. Otherwise, `text/plain`. Default: "html". |
| 1560 | - * @param string|array $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
| 1561 | + * @param string $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
| 1561 | 1562 | * @param array|false $entry Gravity Forms entry array, related to the email. Default: false. |
| 1562 | - * @param array|false $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
| 1563 | + * @param boolean $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
| 1563 | 1564 | */ |
| 1564 | 1565 | public static function send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '', $entry = false, $notification = false ) { |
| 1565 | 1566 | |
@@ -252,12 +252,12 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | - * @hack |
|
| 256 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 257 | - */ |
|
| 255 | + * @hack |
|
| 256 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 257 | + */ |
|
| 258 | 258 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
| 259 | - continue; |
|
| 260 | - } |
|
| 259 | + continue; |
|
| 260 | + } |
|
| 261 | 261 | $fields["{$input['id']}"] = array( |
| 262 | 262 | 'label' => rgar( $input, 'label' ), |
| 263 | 263 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
| 435 | 435 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
| 436 | 436 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
| 437 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
| 437 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
| 438 | 438 | $criteria['context_view_id'] = null; |
| 439 | 439 | } |
| 440 | 440 | |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | ), |
| 1197 | 1197 | ); |
| 1198 | 1198 | |
| 1199 | - $fields = $date_created + $fields; |
|
| 1199 | + $fields = $date_created + $fields; |
|
| 1200 | 1200 | |
| 1201 | 1201 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1202 | 1202 | |
@@ -1208,13 +1208,13 @@ discard block |
||
| 1208 | 1208 | } |
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | - /** |
|
| 1212 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1213 | - * @since 1.12 |
|
| 1214 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1215 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1216 | - */ |
|
| 1217 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1211 | + /** |
|
| 1212 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1213 | + * @since 1.12 |
|
| 1214 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1215 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1216 | + */ |
|
| 1217 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1218 | 1218 | |
| 1219 | 1219 | return $fields; |
| 1220 | 1220 | } |
@@ -1506,26 +1506,26 @@ discard block |
||
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | 1508 | |
| 1509 | - /** |
|
| 1510 | - * Display updated/error notice |
|
| 1511 | - * |
|
| 1512 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
| 1513 | - * |
|
| 1514 | - * @param string $notice text/HTML of notice |
|
| 1515 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1516 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
| 1517 | - * |
|
| 1518 | - * @return string |
|
| 1519 | - */ |
|
| 1520 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
| 1521 | - |
|
| 1522 | - // If $cap is defined, only show notice if user has capability |
|
| 1523 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1524 | - return ''; |
|
| 1525 | - } |
|
| 1526 | - |
|
| 1527 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1528 | - } |
|
| 1509 | + /** |
|
| 1510 | + * Display updated/error notice |
|
| 1511 | + * |
|
| 1512 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
| 1513 | + * |
|
| 1514 | + * @param string $notice text/HTML of notice |
|
| 1515 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1516 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
| 1517 | + * |
|
| 1518 | + * @return string |
|
| 1519 | + */ |
|
| 1520 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
| 1521 | + |
|
| 1522 | + // If $cap is defined, only show notice if user has capability |
|
| 1523 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1524 | + return ''; |
|
| 1525 | + } |
|
| 1526 | + |
|
| 1527 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1528 | + } |
|
| 1529 | 1529 | |
| 1530 | 1530 | /** |
| 1531 | 1531 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $entry = self::get_entry( $entry_slug, true ); |
| 126 | 126 | |
| 127 | - $form = self::get_form( $entry['form_id'] ); |
|
| 127 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 128 | 128 | |
| 129 | 129 | return $form; |
| 130 | 130 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
| 184 | 184 | |
| 185 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 185 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
| 186 | 186 | |
| 187 | 187 | return $result; |
| 188 | 188 | } |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
| 201 | 201 | */ |
| 202 | - public static function get_forms( $active = true, $trash = false ) { |
|
| 202 | + public static function get_forms( $active = true, $trash = false ) { |
|
| 203 | 203 | $forms = array(); |
| 204 | 204 | if ( class_exists( 'GFAPI' ) ) { |
| 205 | - if( 'any' === $active ) { |
|
| 205 | + if ( 'any' === $active ) { |
|
| 206 | 206 | $active_forms = GFAPI::get_forms( true, $trash ); |
| 207 | 207 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
| 208 | 208 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -233,9 +233,9 @@ discard block |
||
| 233 | 233 | $has_post_fields = false; |
| 234 | 234 | |
| 235 | 235 | if ( $form ) { |
| 236 | - foreach ( $form['fields'] as $field ) { |
|
| 237 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 238 | - $fields["{$field['id']}"] = array( |
|
| 236 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 237 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
| 238 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
| 239 | 239 | 'label' => rgar( $field, 'label' ), |
| 240 | 240 | 'parent' => null, |
| 241 | 241 | 'type' => rgar( $field, 'type' ), |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | ); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 248 | - foreach ( $field['inputs'] as $input ) { |
|
| 247 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
| 248 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
| 249 | 249 | |
| 250 | - if( ! empty( $input['isHidden'] ) ) { |
|
| 250 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
| 251 | 251 | continue; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | * @hack |
| 256 | 256 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 257 | 257 | */ |
| 258 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
| 258 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
| 259 | 259 | continue; |
| 260 | 260 | } |
| 261 | - $fields["{$input['id']}"] = array( |
|
| 261 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
| 262 | 262 | 'label' => rgar( $input, 'label' ), |
| 263 | 263 | 'customLabel' => rgar( $input, 'customLabel' ), |
| 264 | 264 | 'parent' => $field, |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | |
| 273 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 273 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
| 274 | 274 | $has_product_fields = true; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @since 1.7 |
| 285 | 285 | */ |
| 286 | 286 | if ( $has_post_fields ) { |
| 287 | - $fields['post_id'] = array( |
|
| 287 | + $fields[ 'post_id' ] = array( |
|
| 288 | 288 | 'label' => __( 'Post ID', 'gravityview' ), |
| 289 | 289 | 'type' => 'post_id', |
| 290 | 290 | ); |
@@ -295,10 +295,10 @@ discard block |
||
| 295 | 295 | $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
| 296 | 296 | |
| 297 | 297 | foreach ( $payment_fields as $payment_field ) { |
| 298 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
| 298 | + if ( isset( $fields[ "{$payment_field->name}" ] ) ) { |
|
| 299 | 299 | continue; |
| 300 | 300 | } |
| 301 | - $fields["{$payment_field->name}"] = array( |
|
| 301 | + $fields[ "{$payment_field->name}" ] = array( |
|
| 302 | 302 | 'label' => $payment_field->label, |
| 303 | 303 | 'desc' => $payment_field->description, |
| 304 | 304 | 'type' => $payment_field->name, |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | $fields = array(); |
| 332 | 332 | |
| 333 | - foreach ( $extra_fields as $key => $field ){ |
|
| 334 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 335 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 333 | + foreach ( $extra_fields as $key => $field ) { |
|
| 334 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
| 335 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
@@ -372,32 +372,32 @@ discard block |
||
| 372 | 372 | 'search_criteria' => null, |
| 373 | 373 | 'sorting' => null, |
| 374 | 374 | 'paging' => null, |
| 375 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
| 375 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ), |
|
| 376 | 376 | ); |
| 377 | 377 | |
| 378 | 378 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
| 379 | 379 | |
| 380 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 381 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 380 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 381 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
| 382 | 382 | |
| 383 | 383 | if ( ! is_array( $filter ) ) { |
| 384 | 384 | continue; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // By default, we want searches to be wildcard for each field. |
| 388 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 388 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 392 | 392 | * @param string $operator Existing search operator |
| 393 | 393 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 394 | 394 | */ |
| 395 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 395 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | // don't send just the [mode] without any field filter. |
| 399 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
| 400 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
| 399 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 400 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | } |
@@ -408,21 +408,21 @@ discard block |
||
| 408 | 408 | * Prepare date formats to be in Gravity Forms DB format; |
| 409 | 409 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 410 | 410 | */ |
| 411 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 411 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
| 412 | 412 | |
| 413 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 413 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
| 414 | 414 | |
| 415 | 415 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 416 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 416 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 417 | 417 | |
| 418 | 418 | if ( $date ) { |
| 419 | 419 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 420 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 420 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 421 | 421 | } else { |
| 422 | 422 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 423 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 423 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 424 | 424 | |
| 425 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
| 425 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -430,12 +430,12 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
| 432 | 432 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
| 433 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 433 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 434 | 434 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
| 435 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
| 436 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
| 435 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
| 436 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
| 437 | 437 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
| 438 | - $criteria['context_view_id'] = null; |
|
| 438 | + $criteria[ 'context_view_id' ] = null; |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * @param array $form_ids Forms to search |
| 445 | 445 | * @param int $view_id ID of the view being used to search |
| 446 | 446 | */ |
| 447 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 447 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
| 448 | 448 | |
| 449 | 449 | return (array)$criteria; |
| 450 | 450 | |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | /** Reduce # of database calls */ |
| 476 | 476 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
| 477 | 477 | |
| 478 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 478 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
| 479 | 479 | |
| 480 | 480 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
| 481 | 481 | |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | // Still update the total count when using cached results |
| 485 | 485 | if ( ! is_null( $total ) ) { |
| 486 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 486 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | $return = $entries; |
@@ -503,9 +503,9 @@ discard block |
||
| 503 | 503 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
| 504 | 504 | |
| 505 | 505 | // No entries returned from gravityview_before_get_entries |
| 506 | - if( is_null( $entries ) ) { |
|
| 506 | + if ( is_null( $entries ) ) { |
|
| 507 | 507 | |
| 508 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 508 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
| 509 | 509 | |
| 510 | 510 | if ( is_wp_error( $entries ) ) { |
| 511 | 511 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 517 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
| 518 | 518 | |
| 519 | 519 | // Cache results |
| 520 | 520 | $Cache->set( $entries, 'entries' ); |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | */ |
| 620 | 620 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
| 621 | 621 | |
| 622 | - if( $check_entry_display ) { |
|
| 622 | + if ( $check_entry_display ) { |
|
| 623 | 623 | // Is the entry allowed |
| 624 | 624 | $entry = self::check_entry_display( $entry ); |
| 625 | 625 | } |
@@ -652,12 +652,12 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | $value = false; |
| 654 | 654 | |
| 655 | - if( 'context' === $val1 ) { |
|
| 655 | + if ( 'context' === $val1 ) { |
|
| 656 | 656 | |
| 657 | 657 | $matching_contexts = array( $val2 ); |
| 658 | 658 | |
| 659 | 659 | // We allow for non-standard contexts. |
| 660 | - switch( $val2 ) { |
|
| 660 | + switch ( $val2 ) { |
|
| 661 | 661 | // Check for either single or edit |
| 662 | 662 | case 'singular': |
| 663 | 663 | $matching_contexts = array( 'single', 'edit' ); |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | return false; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - if ( empty( $entry['form_id'] ) ) { |
|
| 720 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 721 | 721 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
| 722 | 722 | return false; |
| 723 | 723 | } |
@@ -725,26 +725,26 @@ discard block |
||
| 725 | 725 | $criteria = self::calculate_get_entries_criteria(); |
| 726 | 726 | |
| 727 | 727 | // Make sure the current View is connected to the same form as the Entry |
| 728 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 729 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 728 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 729 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
| 730 | 730 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
| 731 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 732 | - 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'] ); |
|
| 731 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
| 732 | + 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' ] ); |
|
| 733 | 733 | return false; |
| 734 | 734 | } |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 737 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
| 738 | 738 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
| 739 | 739 | return $entry; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - $search_criteria = $criteria['search_criteria']; |
|
| 742 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
| 743 | 743 | unset( $criteria ); |
| 744 | 744 | |
| 745 | 745 | // check entry status |
| 746 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 747 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 746 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
| 747 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
| 748 | 748 | return false; |
| 749 | 749 | } |
| 750 | 750 | |
@@ -752,39 +752,39 @@ discard block |
||
| 752 | 752 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 753 | 753 | |
| 754 | 754 | // field_filters |
| 755 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 755 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
| 756 | 756 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
| 757 | 757 | return $entry; |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - $filters = $search_criteria['field_filters']; |
|
| 760 | + $filters = $search_criteria[ 'field_filters' ]; |
|
| 761 | 761 | unset( $search_criteria ); |
| 762 | 762 | |
| 763 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 764 | - unset( $filters['mode'] ); |
|
| 763 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
| 764 | + unset( $filters[ 'mode' ] ); |
|
| 765 | 765 | |
| 766 | - $form = self::get_form( $entry['form_id'] ); |
|
| 766 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 767 | 767 | |
| 768 | 768 | foreach ( $filters as $filter ) { |
| 769 | 769 | |
| 770 | - if ( ! isset( $filter['key'] ) ) { |
|
| 770 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
| 771 | 771 | continue; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - $k = $filter['key']; |
|
| 774 | + $k = $filter[ 'key' ]; |
|
| 775 | 775 | |
| 776 | 776 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
| 777 | 777 | $field_value = $entry[ $k ]; |
| 778 | 778 | $field = null; |
| 779 | 779 | } else { |
| 780 | 780 | $field = self::get_field( $form, $k ); |
| 781 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 781 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 782 | 782 | // If it's a complex field, then fetch the input's value |
| 783 | 783 | $field_value = is_array( $field_value ) ? rgar( $field_value, $k ) : $field_value; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 787 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 786 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
| 787 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
| 788 | 788 | |
| 789 | 789 | // verify if we are already free to go! |
| 790 | 790 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -842,18 +842,18 @@ discard block |
||
| 842 | 842 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 843 | 843 | * @see GFCommon::format_date() for original code |
| 844 | 844 | */ |
| 845 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 845 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 846 | 846 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 847 | 847 | |
| 848 | - $format = rgar( $atts, 'format' ); |
|
| 849 | - $is_human = ! empty( $atts['human'] ); |
|
| 850 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 851 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 852 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 853 | - $include_time = ! empty( $atts['time'] ); |
|
| 848 | + $format = rgar( $atts, 'format' ); |
|
| 849 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 850 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 851 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 852 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 853 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 854 | 854 | |
| 855 | 855 | // If we're using time diff, we want to have a different default format |
| 856 | - if( empty( $format ) ) { |
|
| 856 | + if ( empty( $format ) ) { |
|
| 857 | 857 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
| 858 | 858 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 859 | 859 | } |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | // If raw was specified, don't modify the stored value |
| 862 | 862 | if ( $is_raw ) { |
| 863 | 863 | $formatted_date = $date_string; |
| 864 | - } elseif( $is_timestamp ) { |
|
| 864 | + } elseif ( $is_timestamp ) { |
|
| 865 | 865 | $formatted_date = $date_local_timestamp; |
| 866 | 866 | } elseif ( $is_diff ) { |
| 867 | 867 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | $label = rgar( $field, 'label' ); |
| 897 | 897 | |
| 898 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 898 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 899 | 899 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
| 900 | 900 | } |
| 901 | 901 | |
@@ -923,7 +923,7 @@ discard block |
||
| 923 | 923 | $form = GFAPI::get_form( $form ); |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 926 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 927 | 927 | return GFFormsModel::get_field( $form, $field_id ); |
| 928 | 928 | } else { |
| 929 | 929 | return null; |
@@ -970,19 +970,19 @@ discard block |
||
| 970 | 970 | $shortcodes = array(); |
| 971 | 971 | |
| 972 | 972 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 973 | - if ( empty( $matches ) ){ |
|
| 973 | + if ( empty( $matches ) ) { |
|
| 974 | 974 | return false; |
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | foreach ( $matches as $shortcode ) { |
| 978 | - if ( $tag === $shortcode[2] ) { |
|
| 978 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 979 | 979 | |
| 980 | 980 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 981 | - $shortcodes[] = $shortcode; |
|
| 981 | + $shortcodes[ ] = $shortcode; |
|
| 982 | 982 | |
| 983 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 984 | - foreach( $results as $result ) { |
|
| 985 | - $shortcodes[] = $result; |
|
| 983 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 984 | + foreach ( $results as $result ) { |
|
| 985 | + $shortcodes[ ] = $result; |
|
| 986 | 986 | } |
| 987 | 987 | } |
| 988 | 988 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
| 1127 | 1127 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
| 1128 | 1128 | |
| 1129 | - if( $apply_filter ) { |
|
| 1129 | + if ( $apply_filter ) { |
|
| 1130 | 1130 | /** |
| 1131 | 1131 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
| 1132 | 1132 | * @since 1.6.5 |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | * @return string html |
| 1150 | 1150 | */ |
| 1151 | 1151 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1152 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1152 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1153 | 1153 | |
| 1154 | 1154 | if ( empty( $formid ) ) { |
| 1155 | 1155 | return $output; |
@@ -1162,11 +1162,11 @@ discard block |
||
| 1162 | 1162 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1163 | 1163 | |
| 1164 | 1164 | foreach ( $fields as $id => $field ) { |
| 1165 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1165 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1166 | 1166 | continue; |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1169 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1170 | 1170 | } |
| 1171 | 1171 | } |
| 1172 | 1172 | |
@@ -1201,9 +1201,9 @@ discard block |
||
| 1201 | 1201 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1202 | 1202 | |
| 1203 | 1203 | // TODO: Convert to using array_filter |
| 1204 | - foreach( $fields as $id => $field ) { |
|
| 1204 | + foreach ( $fields as $id => $field ) { |
|
| 1205 | 1205 | |
| 1206 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1206 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1207 | 1207 | unset( $fields[ $id ] ); |
| 1208 | 1208 | } |
| 1209 | 1209 | } |
@@ -1244,14 +1244,14 @@ discard block |
||
| 1244 | 1244 | * @param int|array $field field key or field array |
| 1245 | 1245 | * @return boolean |
| 1246 | 1246 | */ |
| 1247 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1247 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1248 | 1248 | |
| 1249 | 1249 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1250 | 1250 | $form = self::get_form( $form ); |
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | 1253 | // If entry meta, it's a string. Otherwise, numeric |
| 1254 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1254 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1255 | 1255 | $type = $field; |
| 1256 | 1256 | } else { |
| 1257 | 1257 | $type = self::get_field_type( $form, $field ); |
@@ -1265,9 +1265,9 @@ discard block |
||
| 1265 | 1265 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1266 | 1266 | |
| 1267 | 1267 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1268 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1269 | - if( true === $gv_field->is_numeric ) { |
|
| 1270 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1268 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1269 | + if ( true === $gv_field->is_numeric ) { |
|
| 1270 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1271 | 1271 | } |
| 1272 | 1272 | } |
| 1273 | 1273 | |
@@ -1417,18 +1417,18 @@ discard block |
||
| 1417 | 1417 | $final_atts = array_filter( $final_atts ); |
| 1418 | 1418 | |
| 1419 | 1419 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1420 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1421 | - $final_atts['href'] = $href; |
|
| 1420 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1421 | + $final_atts[ 'href' ] = $href; |
|
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1424 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1425 | 1425 | |
| 1426 | 1426 | /** |
| 1427 | 1427 | * Fix potential security issue with target=_blank |
| 1428 | 1428 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
| 1429 | 1429 | */ |
| 1430 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
| 1431 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1430 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
| 1431 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | |
| 1434 | 1434 | // Sort the attributes alphabetically, to help testing |
@@ -1440,7 +1440,7 @@ discard block |
||
| 1440 | 1440 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | - if( '' !== $output ) { |
|
| 1443 | + if ( '' !== $output ) { |
|
| 1444 | 1444 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1445 | 1445 | } |
| 1446 | 1446 | |
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1468 | 1468 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1469 | 1469 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
| 1470 | - $merged[] = $value; |
|
| 1470 | + $merged[ ] = $value; |
|
| 1471 | 1471 | } else { |
| 1472 | 1472 | $merged[ $key ] = $value; |
| 1473 | 1473 | } |
@@ -1500,7 +1500,7 @@ discard block |
||
| 1500 | 1500 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1501 | 1501 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1502 | 1502 | */ |
| 1503 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1503 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1504 | 1504 | |
| 1505 | 1505 | return get_users( $get_users_settings ); |
| 1506 | 1506 | } |
@@ -1520,11 +1520,11 @@ discard block |
||
| 1520 | 1520 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
| 1521 | 1521 | |
| 1522 | 1522 | // If $cap is defined, only show notice if user has capability |
| 1523 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1523 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1524 | 1524 | return ''; |
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1527 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | /** |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * Sets the single entry ID and also the entry |
| 156 | - * @param bool|int|string $single_entry |
|
| 156 | + * @param boolean|string $single_entry |
|
| 157 | 157 | */ |
| 158 | 158 | public function setSingleEntry( $single_entry ) { |
| 159 | 159 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Set the current entry |
| 173 | - * @param array|int $entry Entry array or entry slug or ID |
|
| 173 | + * @param boolean|string $entry Entry array or entry slug or ID |
|
| 174 | 174 | */ |
| 175 | 175 | public function setEntry( $entry ) { |
| 176 | 176 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * |
| 230 | 230 | * |
| 231 | - * @param null $view_id |
|
| 231 | + * @param string $view_id |
|
| 232 | 232 | */ |
| 233 | 233 | public function set_context_view_id( $view_id = null ) { |
| 234 | 234 | |
@@ -558,7 +558,6 @@ discard block |
||
| 558 | 558 | * |
| 559 | 559 | * @since 1.19.2 |
| 560 | 560 | * |
| 561 | - * @param string $context The current context that has no configuration |
|
| 562 | 561 | * |
| 563 | 562 | * @return void |
| 564 | 563 | */ |
@@ -1091,7 +1090,7 @@ discard block |
||
| 1091 | 1090 | * |
| 1092 | 1091 | * @uses gravityview_get_entries() |
| 1093 | 1092 | * @access public |
| 1094 | - * @param array $args\n |
|
| 1093 | + * @param array $args |
|
| 1095 | 1094 | * - $id - View id |
| 1096 | 1095 | * - $page_size - Page |
| 1097 | 1096 | * - $sort_field - form field id to sort |
@@ -1551,7 +1550,7 @@ discard block |
||
| 1551 | 1550 | /** |
| 1552 | 1551 | * Checks if field (column) is sortable |
| 1553 | 1552 | * |
| 1554 | - * @param string $field Field settings |
|
| 1553 | + * @param string $field_id Field settings |
|
| 1555 | 1554 | * @param array $form Gravity Forms form array |
| 1556 | 1555 | * |
| 1557 | 1556 | * @since 1.7 |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | private function __construct() {} |
| 86 | 86 | |
| 87 | 87 | private function initialize() { |
| 88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
| 88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
| 89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
| 90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
| 90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
| 91 | 91 | |
| 92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
| 93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -236,15 +236,15 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $this->context_view_id = $view_id; |
| 238 | 238 | |
| 239 | - } elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
| 239 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
| 240 | 240 | /** |
| 241 | 241 | * used on a has_multiple_views context |
| 242 | 242 | * @see GravityView_API::entry_link |
| 243 | 243 | * @see GravityView_View_Data::getInstance()->has_multiple_views() |
| 244 | 244 | */ |
| 245 | - $this->context_view_id = $_GET['gvid']; |
|
| 245 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
| 246 | 246 | |
| 247 | - } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
| 247 | + } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
| 248 | 248 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
| 249 | 249 | $this->context_view_id = array_pop( $array_keys ); |
| 250 | 250 | unset( $array_keys ); |
@@ -279,24 +279,24 @@ discard block |
||
| 279 | 279 | global $wp_rewrite; |
| 280 | 280 | |
| 281 | 281 | $is_front_page = ( $query->is_home || $query->is_page ); |
| 282 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
| 283 | - $front_page_id = get_option('page_on_front'); |
|
| 282 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
| 283 | + $front_page_id = get_option( 'page_on_front' ); |
|
| 284 | 284 | |
| 285 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
| 285 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
| 286 | 286 | |
| 287 | 287 | // Force to be an array, potentially a query string ( entry=16 ) |
| 288 | 288 | $_query = wp_parse_args( $query->query ); |
| 289 | 289 | |
| 290 | 290 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
| 291 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
| 292 | - unset( $_query['pagename'] ); |
|
| 291 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
| 292 | + unset( $_query[ 'pagename' ] ); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // this is where will break from core wordpress |
| 296 | 296 | $ignore = array( 'preview', 'page', 'paged', 'cpage' ); |
| 297 | 297 | $endpoints = rgobj( $wp_rewrite, 'endpoints' ); |
| 298 | - foreach ( (array) $endpoints as $endpoint ) { |
|
| 299 | - $ignore[] = $endpoint[1]; |
|
| 298 | + foreach ( (array)$endpoints as $endpoint ) { |
|
| 299 | + $ignore[ ] = $endpoint[ 1 ]; |
|
| 300 | 300 | } |
| 301 | 301 | unset( $endpoints ); |
| 302 | 302 | |
@@ -306,21 +306,21 @@ discard block |
||
| 306 | 306 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
| 307 | 307 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
| 308 | 308 | |
| 309 | - $qv =& $query->query_vars; |
|
| 309 | + $qv = & $query->query_vars; |
|
| 310 | 310 | |
| 311 | 311 | // Prevent redirect when on the single entry endpoint |
| 312 | - if( self::is_single_entry() ) { |
|
| 312 | + if ( self::is_single_entry() ) { |
|
| 313 | 313 | add_filter( 'redirect_canonical', '__return_false' ); |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | $query->is_page = true; |
| 317 | 317 | $query->is_home = false; |
| 318 | - $qv['page_id'] = $front_page_id; |
|
| 318 | + $qv[ 'page_id' ] = $front_page_id; |
|
| 319 | 319 | |
| 320 | 320 | // Correct <!--nextpage--> for page_on_front |
| 321 | - if ( ! empty( $qv['paged'] ) ) { |
|
| 322 | - $qv['page'] = $qv['paged']; |
|
| 323 | - unset( $qv['paged'] ); |
|
| 321 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
| 322 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
| 323 | + unset( $qv[ 'paged' ] ); |
|
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | global $post; |
| 339 | 339 | |
| 340 | 340 | // If in admin and NOT AJAX request, get outta here. |
| 341 | - if ( GravityView_Plugin::is_admin() ) { |
|
| 341 | + if ( GravityView_Plugin::is_admin() ) { |
|
| 342 | 342 | return; |
| 343 | 343 | } |
| 344 | 344 | |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
| 352 | 352 | |
| 353 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
| 353 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
| 354 | 354 | $this->setPostId( $post_id ); |
| 355 | 355 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
| 356 | 356 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
| 388 | 388 | |
| 389 | - if( 'post' === $search_method ) { |
|
| 389 | + if ( 'post' === $search_method ) { |
|
| 390 | 390 | $get = $_POST; |
| 391 | 391 | } else { |
| 392 | 392 | $get = $_GET; |
@@ -442,20 +442,20 @@ discard block |
||
| 442 | 442 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
| 443 | 443 | * @param array $entry Current entry |
| 444 | 444 | */ |
| 445 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
| 445 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
| 446 | 446 | |
| 447 | 447 | if ( ! $apply_outside_loop ) { |
| 448 | 448 | return $title; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | // User reported WooCommerce doesn't pass two args. |
| 452 | - if ( empty( $passed_post_id ) ) { |
|
| 452 | + if ( empty( $passed_post_id ) ) { |
|
| 453 | 453 | return $title; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | // Don't modify the title for anything other than the current view/post. |
| 457 | 457 | // This is true for embedded shortcodes and Views. |
| 458 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
| 458 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
| 459 | 459 | return $title; |
| 460 | 460 | } |
| 461 | 461 | |
@@ -465,19 +465,19 @@ discard block |
||
| 465 | 465 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
| 466 | 466 | } else { |
| 467 | 467 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
| 468 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
| 468 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
| 469 | 469 | $view_meta = $view_data; |
| 470 | 470 | break; |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
| 475 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
| 476 | 476 | |
| 477 | - $title = $view_meta['atts']['single_title']; |
|
| 477 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
| 478 | 478 | |
| 479 | 479 | // We are allowing HTML in the fields, so no escaping the output |
| 480 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
| 480 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
| 481 | 481 | |
| 482 | 482 | $title = do_shortcode( $title ); |
| 483 | 483 | } |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | |
| 573 | 573 | $context = GravityView_View::getInstance()->getContext(); |
| 574 | 574 | |
| 575 | - switch( $context ) { |
|
| 575 | + switch ( $context ) { |
|
| 576 | 576 | case 'directory': |
| 577 | 577 | $tab = __( 'Multiple Entries', 'gravityview' ); |
| 578 | 578 | break; |
@@ -586,9 +586,9 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | |
| 589 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
| 589 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
| 590 | 590 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
| 591 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
| 591 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
| 592 | 592 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
| 593 | 593 | |
| 594 | 594 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | public function render_view( $passed_args ) { |
| 622 | 622 | |
| 623 | 623 | // validate attributes |
| 624 | - if ( empty( $passed_args['id'] ) ) { |
|
| 624 | + if ( empty( $passed_args[ 'id' ] ) ) { |
|
| 625 | 625 | do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args ); |
| 626 | 626 | return null; |
| 627 | 627 | } |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | return null; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $view_id = $passed_args['id']; |
|
| 646 | + $view_id = $passed_args[ 'id' ]; |
|
| 647 | 647 | |
| 648 | 648 | $view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args ); |
| 649 | 649 | |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | $passed_args = array_filter( $passed_args, 'strlen' ); |
| 657 | 657 | |
| 658 | 658 | //Override shortcode args over View template settings |
| 659 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] ); |
|
| 659 | + $atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] ); |
|
| 660 | 660 | |
| 661 | 661 | do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts ); |
| 662 | 662 | |
@@ -679,14 +679,14 @@ discard block |
||
| 679 | 679 | * @since 1.15 |
| 680 | 680 | * @since 1.17.2 Added check for if a user has no caps but is logged in (member of multisite, but not any site). Treat as if logged-out. |
| 681 | 681 | */ |
| 682 | - if( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 682 | + if ( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 683 | 683 | |
| 684 | 684 | do_action( 'gravityview_log_debug', sprintf( '%s Returning: View %d is not visible by current user.', __METHOD__, $view_id ) ); |
| 685 | 685 | |
| 686 | 686 | return null; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - if( $this->isGravityviewPostType() ) { |
|
| 689 | + if ( $this->isGravityviewPostType() ) { |
|
| 690 | 690 | |
| 691 | 691 | /** |
| 692 | 692 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode? |
@@ -698,9 +698,9 @@ discard block |
||
| 698 | 698 | */ |
| 699 | 699 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view_id ); |
| 700 | 700 | |
| 701 | - $embed_only = ! empty( $atts['embed_only'] ); |
|
| 701 | + $embed_only = ! empty( $atts[ 'embed_only' ] ); |
|
| 702 | 702 | |
| 703 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
| 703 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
| 704 | 704 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 705 | 705 | } |
| 706 | 706 | } |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | |
| 716 | 716 | $gravityview_view = new GravityView_View( $view_data ); |
| 717 | 717 | |
| 718 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId(); |
|
| 718 | + $post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : $this->getPostId(); |
|
| 719 | 719 | |
| 720 | 720 | $gravityview_view->setPostId( $post_id ); |
| 721 | 721 | |
@@ -725,20 +725,20 @@ discard block |
||
| 725 | 725 | do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' ); |
| 726 | 726 | |
| 727 | 727 | //fetch template and slug |
| 728 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' ); |
|
| 728 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'directory' ); |
|
| 729 | 729 | |
| 730 | 730 | do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug ); |
| 731 | 731 | |
| 732 | 732 | /** |
| 733 | 733 | * Disable fetching initial entries for views that don't need it (DataTables) |
| 734 | 734 | */ |
| 735 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true ); |
|
| 735 | + $get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true ); |
|
| 736 | 736 | |
| 737 | 737 | /** |
| 738 | 738 | * Hide View data until search is performed |
| 739 | 739 | * @since 1.5.4 |
| 740 | 740 | */ |
| 741 | - if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) { |
|
| 741 | + if ( ! empty( $atts[ 'hide_until_searched' ] ) && ! $this->isSearch() ) { |
|
| 742 | 742 | $gravityview_view->setHideUntilSearched( true ); |
| 743 | 743 | $get_entries = false; |
| 744 | 744 | } |
@@ -746,23 +746,23 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | if ( $get_entries ) { |
| 748 | 748 | |
| 749 | - if ( ! empty( $atts['sort_columns'] ) ) { |
|
| 749 | + if ( ! empty( $atts[ 'sort_columns' ] ) ) { |
|
| 750 | 750 | // add filter to enable column sorting |
| 751 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 ); |
|
| 751 | + add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 ); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] ); |
|
| 754 | + $view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] ); |
|
| 755 | 755 | |
| 756 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) ); |
|
| 756 | + do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) ); |
|
| 757 | 757 | |
| 758 | 758 | } else { |
| 759 | 759 | |
| 760 | 760 | $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null ); |
| 761 | 761 | |
| 762 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' ); |
|
| 762 | + do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' ); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - $gravityview_view->setPaging( $view_entries['paging'] ); |
|
| 765 | + $gravityview_view->setPaging( $view_entries[ 'paging' ] ); |
|
| 766 | 766 | $gravityview_view->setContext( 'directory' ); |
| 767 | 767 | $sections = array( 'header', 'body', 'footer' ); |
| 768 | 768 | |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID |
| 777 | 777 | * @since 1.17 |
| 778 | 778 | */ |
| 779 | - do_action( 'gravityview_render_entry_'.$view_data['id'] ); |
|
| 779 | + do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] ); |
|
| 780 | 780 | |
| 781 | 781 | $entry = $this->getEntry(); |
| 782 | 782 | |
@@ -803,20 +803,20 @@ discard block |
||
| 803 | 803 | // We're in single view, but the view being processed is not the same view the single entry belongs to. |
| 804 | 804 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms |
| 805 | 805 | if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) { |
| 806 | - do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id ); |
|
| 806 | + do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id ); |
|
| 807 | 807 | return null; |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | //fetch template and slug |
| 811 | - $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' ); |
|
| 811 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'single' ); |
|
| 812 | 812 | do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug ); |
| 813 | 813 | |
| 814 | 814 | //fetch entry detail |
| 815 | - $view_entries['count'] = 1; |
|
| 816 | - $view_entries['entries'][] = $entry; |
|
| 817 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] ); |
|
| 815 | + $view_entries[ 'count' ] = 1; |
|
| 816 | + $view_entries[ 'entries' ][ ] = $entry; |
|
| 817 | + do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] ); |
|
| 818 | 818 | |
| 819 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null; |
|
| 819 | + $back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null; |
|
| 820 | 820 | |
| 821 | 821 | // set back link label |
| 822 | 822 | $gravityview_view->setBackLinkLabel( $back_link_label ); |
@@ -826,11 +826,11 @@ discard block |
||
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | // add template style |
| 829 | - self::add_style( $view_data['template_id'] ); |
|
| 829 | + self::add_style( $view_data[ 'template_id' ] ); |
|
| 830 | 830 | |
| 831 | 831 | // Prepare to render view and set vars |
| 832 | - $gravityview_view->setEntries( $view_entries['entries'] ); |
|
| 833 | - $gravityview_view->setTotalEntries( $view_entries['count'] ); |
|
| 832 | + $gravityview_view->setEntries( $view_entries[ 'entries' ] ); |
|
| 833 | + $gravityview_view->setTotalEntries( $view_entries[ 'count' ] ); |
|
| 834 | 834 | |
| 835 | 835 | // If Edit |
| 836 | 836 | if ( 'edit' === gravityview_get_context() ) { |
@@ -843,11 +843,11 @@ discard block |
||
| 843 | 843 | |
| 844 | 844 | } else { |
| 845 | 845 | // finaly we'll render some html |
| 846 | - $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] ); |
|
| 846 | + $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data[ 'template_id' ] ); |
|
| 847 | 847 | |
| 848 | 848 | do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections ); |
| 849 | 849 | foreach ( $sections as $section ) { |
| 850 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' ); |
|
| 850 | + do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' ); |
|
| 851 | 851 | $gravityview_view->render( $view_slug, $section, false ); |
| 852 | 852 | } |
| 853 | 853 | } |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | $datetime_format = 'Y-m-d H:i:s'; |
| 902 | 902 | $search_is_outside_view_bounds = false; |
| 903 | 903 | |
| 904 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
| 904 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
| 905 | 905 | |
| 906 | 906 | $search_date = strtotime( $search_criteria[ $key ] ); |
| 907 | 907 | |
@@ -929,14 +929,14 @@ discard block |
||
| 929 | 929 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
| 930 | 930 | |
| 931 | 931 | // Then we override the search and re-set the start date |
| 932 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
| 932 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
| 933 | 933 | } |
| 934 | 934 | } |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
| 937 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
| 938 | 938 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
| 939 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
| 939 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
| 940 | 940 | do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria ); |
| 941 | 941 | } |
| 942 | 942 | } |
@@ -955,19 +955,19 @@ discard block |
||
| 955 | 955 | public static function process_search_only_approved( $args, $search_criteria ) { |
| 956 | 956 | |
| 957 | 957 | /** @since 1.19 */ |
| 958 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
| 958 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 959 | 959 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries; showing all approval statuses' ); |
| 960 | 960 | return $search_criteria; |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
| 963 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
| 964 | 964 | |
| 965 | - $search_criteria['field_filters'][] = array( |
|
| 965 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 966 | 966 | 'key' => GravityView_Entry_Approval::meta_key, |
| 967 | 967 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
| 968 | 968 | ); |
| 969 | 969 | |
| 970 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
| 970 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
| 971 | 971 | |
| 972 | 972 | do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria ); |
| 973 | 973 | } |
@@ -994,18 +994,18 @@ discard block |
||
| 994 | 994 | */ |
| 995 | 995 | public static function is_entry_approved( $entry, $args = array() ) { |
| 996 | 996 | |
| 997 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
| 997 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
| 998 | 998 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
| 999 | 999 | return true; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** @since 1.19 */ |
| 1003 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
| 1003 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 1004 | 1004 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries, so entry is approved for viewing' ); |
| 1005 | 1005 | return true; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
| 1008 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
| 1009 | 1009 | |
| 1010 | 1010 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
| 1011 | 1011 | } |
@@ -1039,26 +1039,26 @@ discard block |
||
| 1039 | 1039 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria ); |
| 1040 | 1040 | |
| 1041 | 1041 | // implicity search |
| 1042 | - if ( ! empty( $args['search_value'] ) ) { |
|
| 1042 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
| 1043 | 1043 | |
| 1044 | 1044 | // Search operator options. Options: `is` or `contains` |
| 1045 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
| 1045 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
| 1046 | 1046 | |
| 1047 | - $search_criteria['field_filters'][] = array( |
|
| 1047 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 1048 | 1048 | 'key' => rgget( 'search_field', $args ), // The field ID to search |
| 1049 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
| 1049 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
| 1050 | 1050 | 'operator' => $operator, |
| 1051 | 1051 | ); |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - if( $search_criteria !== $original_search_criteria ) { |
|
| 1054 | + if ( $search_criteria !== $original_search_criteria ) { |
|
| 1055 | 1055 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria ); |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | // Handle setting date range |
| 1059 | 1059 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
| 1060 | 1060 | |
| 1061 | - if( $search_criteria !== $original_search_criteria ) { |
|
| 1061 | + if ( $search_criteria !== $original_search_criteria ) { |
|
| 1062 | 1062 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria ); |
| 1063 | 1063 | } |
| 1064 | 1064 | |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
| 1070 | 1070 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
| 1071 | 1071 | */ |
| 1072 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
| 1072 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
| 1073 | 1073 | |
| 1074 | 1074 | return $search_criteria; |
| 1075 | 1075 | } |
@@ -1115,16 +1115,16 @@ discard block |
||
| 1115 | 1115 | $search_criteria = self::get_search_criteria( $args, $form_id ); |
| 1116 | 1116 | |
| 1117 | 1117 | // Paging & offset |
| 1118 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
| 1118 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
| 1119 | 1119 | |
| 1120 | 1120 | if ( -1 === $page_size ) { |
| 1121 | 1121 | $page_size = PHP_INT_MAX; |
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - if ( isset( $args['offset'] ) ) { |
|
| 1125 | - $offset = intval( $args['offset'] ); |
|
| 1124 | + if ( isset( $args[ 'offset' ] ) ) { |
|
| 1125 | + $offset = intval( $args[ 'offset' ] ); |
|
| 1126 | 1126 | } else { |
| 1127 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
| 1127 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
| 1128 | 1128 | $offset = ( $curr_page - 1 ) * $page_size; |
| 1129 | 1129 | } |
| 1130 | 1130 | |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | 'search_criteria' => $search_criteria, |
| 1143 | 1143 | 'sorting' => $sorting, |
| 1144 | 1144 | 'paging' => $paging, |
| 1145 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
| 1145 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
| 1146 | 1146 | ); |
| 1147 | 1147 | |
| 1148 | 1148 | /** |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
| 1168 | 1168 | * @param array $args View configuration args. |
| 1169 | 1169 | */ |
| 1170 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id ); |
|
| 1170 | + $parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id ); |
|
| 1171 | 1171 | |
| 1172 | 1172 | do_action( 'gravityview_log_debug', __METHOD__ . ': $parameters passed to gravityview_get_entries(): ', $parameters ); |
| 1173 | 1173 | |
@@ -1207,8 +1207,8 @@ discard block |
||
| 1207 | 1207 | */ |
| 1208 | 1208 | public static function updateViewSorting( $args, $form_id ) { |
| 1209 | 1209 | $sorting = array(); |
| 1210 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' ); |
|
| 1211 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' ); |
|
| 1210 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' ); |
|
| 1211 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' ); |
|
| 1212 | 1212 | |
| 1213 | 1213 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
| 1214 | 1214 | |
@@ -1248,11 +1248,11 @@ discard block |
||
| 1248 | 1248 | |
| 1249 | 1249 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
| 1250 | 1250 | |
| 1251 | - if( ! $sort_field ) { |
|
| 1251 | + if ( ! $sort_field ) { |
|
| 1252 | 1252 | return $sort_field_id; |
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | - switch ( $sort_field['type'] ) { |
|
| 1255 | + switch ( $sort_field[ 'type' ] ) { |
|
| 1256 | 1256 | |
| 1257 | 1257 | case 'address': |
| 1258 | 1258 | // Sorting by full address |
@@ -1269,7 +1269,7 @@ discard block |
||
| 1269 | 1269 | */ |
| 1270 | 1270 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
| 1271 | 1271 | |
| 1272 | - switch( strtolower( $address_part ) ){ |
|
| 1272 | + switch ( strtolower( $address_part ) ) { |
|
| 1273 | 1273 | case 'street': |
| 1274 | 1274 | $sort_field_id .= '.1'; |
| 1275 | 1275 | break; |
@@ -1349,7 +1349,7 @@ discard block |
||
| 1349 | 1349 | */ |
| 1350 | 1350 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
| 1351 | 1351 | |
| 1352 | - if ( empty( $single_entry ) ){ |
|
| 1352 | + if ( empty( $single_entry ) ) { |
|
| 1353 | 1353 | return false; |
| 1354 | 1354 | } else { |
| 1355 | 1355 | return $single_entry; |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
| 1377 | 1377 | * @since 1.15 |
| 1378 | 1378 | */ |
| 1379 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 1379 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 1380 | 1380 | continue; |
| 1381 | 1381 | } |
| 1382 | 1382 | |
@@ -1385,19 +1385,19 @@ discard block |
||
| 1385 | 1385 | $css_dependencies = array(); |
| 1386 | 1386 | |
| 1387 | 1387 | // If the thickbox is enqueued, add dependencies |
| 1388 | - if ( ! empty( $data['atts']['lightbox'] ) ) { |
|
| 1388 | + if ( ! empty( $data[ 'atts' ][ 'lightbox' ] ) ) { |
|
| 1389 | 1389 | |
| 1390 | 1390 | /** |
| 1391 | 1391 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
| 1392 | 1392 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
| 1393 | 1393 | */ |
| 1394 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
| 1394 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
| 1395 | 1395 | |
| 1396 | 1396 | /** |
| 1397 | 1397 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
| 1398 | 1398 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
| 1399 | 1399 | */ |
| 1400 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
| 1400 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | 1403 | /** |
@@ -1405,25 +1405,25 @@ discard block |
||
| 1405 | 1405 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
| 1406 | 1406 | * @since 1.15 |
| 1407 | 1407 | */ |
| 1408 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
| 1409 | - $css_dependencies[] = 'dashicons'; |
|
| 1408 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
| 1409 | + $css_dependencies[ ] = 'dashicons'; |
|
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | 1412 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
| 1413 | 1413 | |
| 1414 | 1414 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 1415 | 1415 | |
| 1416 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
| 1416 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
| 1417 | 1417 | |
| 1418 | 1418 | wp_enqueue_script( 'gravityview-fe-view' ); |
| 1419 | 1419 | |
| 1420 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
| 1420 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
| 1421 | 1421 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | $this->enqueue_default_style( $css_dependencies ); |
| 1425 | 1425 | |
| 1426 | - self::add_style( $data['template_id'] ); |
|
| 1426 | + self::add_style( $data[ 'template_id' ] ); |
|
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | 1429 | if ( 'wp_print_footer_scripts' === current_filter() ) { |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | } elseif ( empty( $template_id ) ) { |
| 1486 | 1486 | do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' ); |
| 1487 | 1487 | } else { |
| 1488 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) ); |
|
| 1488 | + do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) ); |
|
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | 1491 | } |
@@ -1510,11 +1510,11 @@ discard block |
||
| 1510 | 1510 | * Not a table-based template; don't add sort icons |
| 1511 | 1511 | * @since 1.12 |
| 1512 | 1512 | */ |
| 1513 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
| 1513 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
| 1514 | 1514 | return $label; |
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
| 1517 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
| 1518 | 1518 | return $label; |
| 1519 | 1519 | } |
| 1520 | 1520 | |
@@ -1522,29 +1522,29 @@ discard block |
||
| 1522 | 1522 | |
| 1523 | 1523 | $class = 'gv-sort'; |
| 1524 | 1524 | |
| 1525 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
| 1525 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
| 1526 | 1526 | |
| 1527 | 1527 | $sort_args = array( |
| 1528 | - 'sort' => $field['id'], |
|
| 1528 | + 'sort' => $field[ 'id' ], |
|
| 1529 | 1529 | 'dir' => 'asc', |
| 1530 | 1530 | ); |
| 1531 | 1531 | |
| 1532 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
| 1532 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
| 1533 | 1533 | //toggle sorting direction. |
| 1534 | - if ( 'asc' === $sorting['direction'] ) { |
|
| 1535 | - $sort_args['dir'] = 'desc'; |
|
| 1534 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
| 1535 | + $sort_args[ 'dir' ] = 'desc'; |
|
| 1536 | 1536 | $class .= ' gv-icon-sort-desc'; |
| 1537 | 1537 | } else { |
| 1538 | - $sort_args['dir'] = 'asc'; |
|
| 1538 | + $sort_args[ 'dir' ] = 'asc'; |
|
| 1539 | 1539 | $class .= ' gv-icon-sort-asc'; |
| 1540 | 1540 | } |
| 1541 | 1541 | } else { |
| 1542 | 1542 | $class .= ' gv-icon-caret-up-down'; |
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
| 1545 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
| 1546 | 1546 | |
| 1547 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
| 1547 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
| 1548 | 1548 | |
| 1549 | 1549 | } |
| 1550 | 1550 | |
@@ -1562,7 +1562,7 @@ discard block |
||
| 1562 | 1562 | |
| 1563 | 1563 | $field_type = $field_id; |
| 1564 | 1564 | |
| 1565 | - if( is_numeric( $field_id ) ) { |
|
| 1565 | + if ( is_numeric( $field_id ) ) { |
|
| 1566 | 1566 | $field = GFFormsModel::get_field( $form, $field_id ); |
| 1567 | 1567 | $field_type = $field->type; |
| 1568 | 1568 | } |
@@ -1585,7 +1585,7 @@ discard block |
||
| 1585 | 1585 | return false; |
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1588 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1589 | 1589 | |
| 1590 | 1590 | } |
| 1591 | 1591 | |
@@ -329,34 +329,34 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | - * Get the fields for a specific context |
|
| 333 | - * |
|
| 334 | - * @since 1.19.2 |
|
| 335 | - * |
|
| 332 | + * Get the fields for a specific context |
|
| 333 | + * |
|
| 334 | + * @since 1.19.2 |
|
| 335 | + * |
|
| 336 | 336 | * @param string $context [Optional] "directory", "single", or "edit" |
| 337 | 337 | * |
| 338 | 338 | * @return array Array of GravityView field layout configurations |
| 339 | 339 | */ |
| 340 | 340 | public function getContextFields( $context = '' ) { |
| 341 | 341 | |
| 342 | - if( '' === $context ) { |
|
| 343 | - $context = $this->getContext(); |
|
| 344 | - } |
|
| 342 | + if( '' === $context ) { |
|
| 343 | + $context = $this->getContext(); |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | $fields = $this->getFields(); |
| 347 | 347 | |
| 348 | - foreach ( (array) $fields as $key => $context_fields ) { |
|
| 348 | + foreach ( (array) $fields as $key => $context_fields ) { |
|
| 349 | 349 | |
| 350 | - // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
|
| 351 | - $matches = explode( '_', $key ); |
|
| 350 | + // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
|
| 351 | + $matches = explode( '_', $key ); |
|
| 352 | 352 | |
| 353 | - if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 354 | - return $context_fields; |
|
| 355 | - } |
|
| 356 | - } |
|
| 353 | + if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 354 | + return $context_fields; |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | 358 | return array(); |
| 359 | - } |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * @param array $fields |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | public function getPaging() { |
| 451 | 451 | |
| 452 | - $default_params = array( |
|
| 453 | - 'offset' => 0, |
|
| 454 | - 'page_size' => 20, |
|
| 455 | - ); |
|
| 452 | + $default_params = array( |
|
| 453 | + 'offset' => 0, |
|
| 454 | + 'page_size' => 20, |
|
| 455 | + ); |
|
| 456 | 456 | |
| 457 | 457 | return wp_parse_args( $this->paging, $default_params ); |
| 458 | 458 | } |
@@ -509,10 +509,10 @@ discard block |
||
| 509 | 509 | public function getSorting() { |
| 510 | 510 | |
| 511 | 511 | $defaults_params = array( |
| 512 | - 'sort_field' => 'date_created', |
|
| 513 | - 'sort_direction' => 'ASC', |
|
| 514 | - 'is_numeric' => false, |
|
| 515 | - ); |
|
| 512 | + 'sort_field' => 'date_created', |
|
| 513 | + 'sort_direction' => 'ASC', |
|
| 514 | + 'is_numeric' => false, |
|
| 515 | + ); |
|
| 516 | 516 | |
| 517 | 517 | return wp_parse_args( $this->sorting, $defaults_params ); |
| 518 | 518 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | die; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
| 19 | +if ( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
| 20 | 20 | require( GRAVITYVIEW_DIR . 'includes/lib/class-gamajo-template-loader.php' ); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | 'atts' => NULL, |
| 158 | 158 | ) ); |
| 159 | 159 | |
| 160 | - foreach ($atts as $key => $value) { |
|
| 161 | - if( is_null( $value ) ) { |
|
| 160 | + foreach ( $atts as $key => $value ) { |
|
| 161 | + if ( is_null( $value ) ) { |
|
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | $this->{$key} = $value; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | static function getInstance( $passed_post = NULL ) { |
| 191 | 191 | |
| 192 | - if( empty( self::$instance ) ) { |
|
| 192 | + if ( empty( self::$instance ) ) { |
|
| 193 | 193 | self::$instance = new self( $passed_post ); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function getCurrentField( $key = NULL ) { |
| 204 | 204 | |
| 205 | - if( !empty( $key ) ) { |
|
| 206 | - if( isset( $this->_current_field[ $key ] ) ) { |
|
| 205 | + if ( ! empty( $key ) ) { |
|
| 206 | + if ( isset( $this->_current_field[ $key ] ) ) { |
|
| 207 | 207 | return $this->_current_field[ $key ]; |
| 208 | 208 | } |
| 209 | 209 | return NULL; |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | public function setCurrentFieldSetting( $key, $value ) { |
| 216 | 216 | |
| 217 | - if( !empty( $this->_current_field ) ) { |
|
| 218 | - $this->_current_field['field_settings'][ $key ] = $value; |
|
| 217 | + if ( ! empty( $this->_current_field ) ) { |
|
| 218 | + $this->_current_field[ 'field_settings' ][ $key ] = $value; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | public function getCurrentFieldSetting( $key ) { |
| 224 | - $settings = $this->getCurrentField('field_settings'); |
|
| 224 | + $settings = $this->getCurrentField( 'field_settings' ); |
|
| 225 | 225 | |
| 226 | - if( $settings && !empty( $settings[ $key ] ) ) { |
|
| 226 | + if ( $settings && ! empty( $settings[ $key ] ) ) { |
|
| 227 | 227 | return $settings[ $key ]; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | public function getAtts( $key = NULL ) { |
| 256 | 256 | |
| 257 | - if( !empty( $key ) ) { |
|
| 258 | - if( isset( $this->atts[ $key ] ) ) { |
|
| 257 | + if ( ! empty( $key ) ) { |
|
| 258 | + if ( isset( $this->atts[ $key ] ) ) { |
|
| 259 | 259 | return $this->atts[ $key ]; |
| 260 | 260 | } |
| 261 | 261 | return NULL; |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | $fields = empty( $this->fields ) ? NULL : $this->fields; |
| 323 | 323 | |
| 324 | - if( $fields && !empty( $key ) ) { |
|
| 324 | + if ( $fields && ! empty( $key ) ) { |
|
| 325 | 325 | $fields = isset( $fields[ $key ] ) ? $fields[ $key ] : NULL; |
| 326 | 326 | } |
| 327 | 327 | |
@@ -339,18 +339,18 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | public function getContextFields( $context = '' ) { |
| 341 | 341 | |
| 342 | - if( '' === $context ) { |
|
| 342 | + if ( '' === $context ) { |
|
| 343 | 343 | $context = $this->getContext(); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $fields = $this->getFields(); |
| 347 | 347 | |
| 348 | - foreach ( (array) $fields as $key => $context_fields ) { |
|
| 348 | + foreach ( (array)$fields as $key => $context_fields ) { |
|
| 349 | 349 | |
| 350 | 350 | // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
| 351 | 351 | $matches = explode( '_', $key ); |
| 352 | 352 | |
| 353 | - if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 353 | + if ( isset( $matches[ 0 ] ) && $matches[ 0 ] === $context ) { |
|
| 354 | 354 | return $context_fields; |
| 355 | 355 | } |
| 356 | 356 | } |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | public function getField( $key ) { |
| 373 | 373 | |
| 374 | - if( !empty( $key ) ) { |
|
| 375 | - if( isset( $this->fields[ $key ] ) ) { |
|
| 374 | + if ( ! empty( $key ) ) { |
|
| 375 | + if ( isset( $this->fields[ $key ] ) ) { |
|
| 376 | 376 | return $this->fields[ $key ]; |
| 377 | 377 | } |
| 378 | 378 | } |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | public function getPaginationCounts() { |
| 479 | 479 | |
| 480 | 480 | $paging = $this->getPaging(); |
| 481 | - $offset = $paging['offset']; |
|
| 482 | - $page_size = $paging['page_size']; |
|
| 481 | + $offset = $paging[ 'offset' ]; |
|
| 482 | + $page_size = $paging[ 'page_size' ]; |
|
| 483 | 483 | $total = $this->getTotalEntries(); |
| 484 | 484 | |
| 485 | 485 | if ( empty( $total ) ) { |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | */ |
| 501 | 501 | list( $first, $last, $total ) = apply_filters( 'gravityview_pagination_counts', array( $first, $last, $total ) ); |
| 502 | 502 | |
| 503 | - return array( 'first' => (int) $first, 'last' => (int) $last, 'total' => (int) $total ); |
|
| 503 | + return array( 'first' => (int)$first, 'last' => (int)$last, 'total' => (int)$total ); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -591,16 +591,16 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | public function getCurrentEntry() { |
| 593 | 593 | |
| 594 | - if( in_array( $this->getContext(), array( 'edit', 'single') ) ) { |
|
| 594 | + if ( in_array( $this->getContext(), array( 'edit', 'single' ) ) ) { |
|
| 595 | 595 | $entries = $this->getEntries(); |
| 596 | - $entry = $entries[0]; |
|
| 596 | + $entry = $entries[ 0 ]; |
|
| 597 | 597 | } else { |
| 598 | 598 | $entry = $this->_current_entry; |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** @since 1.16 Fixes DataTables empty entry issue */ |
| 602 | - if ( empty( $entry ) && ! empty( $this->_current_field['entry'] ) ) { |
|
| 603 | - $entry = $this->_current_field['entry']; |
|
| 602 | + if ( empty( $entry ) && ! empty( $this->_current_field[ 'entry' ] ) ) { |
|
| 603 | + $entry = $this->_current_field[ 'entry' ]; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | return $entry; |
@@ -637,8 +637,8 @@ discard block |
||
| 637 | 637 | */ |
| 638 | 638 | public function renderZone( $zone = '', $atts = array(), $echo = true ) { |
| 639 | 639 | |
| 640 | - if( empty( $zone ) ) { |
|
| 641 | - do_action('gravityview_log_error', 'GravityView_View[renderZone] No zone defined.'); |
|
| 640 | + if ( empty( $zone ) ) { |
|
| 641 | + do_action( 'gravityview_log_error', 'GravityView_View[renderZone] No zone defined.' ); |
|
| 642 | 642 | return NULL; |
| 643 | 643 | } |
| 644 | 644 | |
@@ -647,34 +647,34 @@ discard block |
||
| 647 | 647 | 'context' => $this->getContext(), |
| 648 | 648 | 'entry' => $this->getCurrentEntry(), |
| 649 | 649 | 'form' => $this->getForm(), |
| 650 | - 'hide_empty' => $this->getAtts('hide_empty'), |
|
| 650 | + 'hide_empty' => $this->getAtts( 'hide_empty' ), |
|
| 651 | 651 | ); |
| 652 | 652 | |
| 653 | 653 | $final_atts = wp_parse_args( $atts, $defaults ); |
| 654 | 654 | |
| 655 | 655 | $output = ''; |
| 656 | 656 | |
| 657 | - $final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}"; |
|
| 657 | + $final_atts[ 'zone_id' ] = "{$final_atts[ 'context' ]}_{$final_atts[ 'slug' ]}-{$zone}"; |
|
| 658 | 658 | |
| 659 | - $fields = $this->getField( $final_atts['zone_id'] ); |
|
| 659 | + $fields = $this->getField( $final_atts[ 'zone_id' ] ); |
|
| 660 | 660 | |
| 661 | 661 | // Backward compatibility |
| 662 | - if( 'table' === $this->getTemplatePartSlug() ) { |
|
| 662 | + if ( 'table' === $this->getTemplatePartSlug() ) { |
|
| 663 | 663 | /** |
| 664 | 664 | * @filter `gravityview_table_cells` Modify the fields displayed in a table |
| 665 | 665 | * @param array $fields |
| 666 | 666 | * @param GravityView_View $this |
| 667 | 667 | */ |
| 668 | - $fields = apply_filters("gravityview_table_cells", $fields, $this ); |
|
| 668 | + $fields = apply_filters( "gravityview_table_cells", $fields, $this ); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - if( empty( $fields ) ) { |
|
| 671 | + if ( empty( $fields ) ) { |
|
| 672 | 672 | return NULL; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | $field_output = ''; |
| 676 | 676 | foreach ( $fields as $field ) { |
| 677 | - $final_atts['field'] = $field; |
|
| 677 | + $final_atts[ 'field' ] = $field; |
|
| 678 | 678 | |
| 679 | 679 | $field_output .= gravityview_field_output( $final_atts ); |
| 680 | 680 | } |
@@ -685,21 +685,21 @@ discard block |
||
| 685 | 685 | * @since 1.7.6 |
| 686 | 686 | * @param boolean $hide_empty_zone Default: false |
| 687 | 687 | */ |
| 688 | - if( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
| 688 | + if ( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
| 689 | 689 | return NULL; |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 693 | - $output .= '<div class="'.gravityview_sanitize_html_class( $final_atts['wrapper_class'] ).'">'; |
|
| 692 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 693 | + $output .= '<div class="' . gravityview_sanitize_html_class( $final_atts[ 'wrapper_class' ] ) . '">'; |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | $output .= $field_output; |
| 697 | 697 | |
| 698 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 698 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 699 | 699 | $output .= '</div>'; |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - if( $echo ) { |
|
| 702 | + if ( $echo ) { |
|
| 703 | 703 | echo $output; |
| 704 | 704 | } |
| 705 | 705 | |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | */ |
| 718 | 718 | function locate_template( $template_names, $load = false, $require_once = true ) { |
| 719 | 719 | |
| 720 | - if( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 720 | + if ( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 721 | 721 | |
| 722 | 722 | $located = $this->located_templates[ $template_names ]; |
| 723 | 723 | |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | // Set $load to always false so we handle it here. |
| 727 | 727 | $located = parent::locate_template( $template_names, false, $require_once ); |
| 728 | 728 | |
| 729 | - if( is_string( $template_names ) ) { |
|
| 729 | + if ( is_string( $template_names ) ) { |
|
| 730 | 730 | $this->located_templates[ $template_names ] = $located; |
| 731 | 731 | } |
| 732 | 732 | } |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | * @return mixed|null The stored data. |
| 745 | 745 | */ |
| 746 | 746 | public function __get( $name ) { |
| 747 | - if( isset( $this->{$name} ) ) { |
|
| 747 | + if ( isset( $this->{$name} ) ) { |
|
| 748 | 748 | return $this->{$name}; |
| 749 | 749 | } else { |
| 750 | 750 | return NULL; |
@@ -773,15 +773,15 @@ discard block |
||
| 773 | 773 | $additional = array(); |
| 774 | 774 | |
| 775 | 775 | // form-19-table-body.php |
| 776 | - $additional[] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 776 | + $additional[ ] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 777 | 777 | |
| 778 | 778 | // view-3-table-body.php |
| 779 | - $additional[] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
| 779 | + $additional[ ] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
| 780 | 780 | |
| 781 | - if( $this->getPostId() ) { |
|
| 781 | + if ( $this->getPostId() ) { |
|
| 782 | 782 | |
| 783 | 783 | // page-19-table-body.php |
| 784 | - $additional[] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 784 | + $additional[ ] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | // Combine with existing table-body.php and table.php |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | |
| 804 | 804 | do_action( 'gravityview_log_debug', '[render] Rendering Template File', $template_file ); |
| 805 | 805 | |
| 806 | - if( !empty( $template_file) ) { |
|
| 806 | + if ( ! empty( $template_file ) ) { |
|
| 807 | 807 | |
| 808 | 808 | if ( $require_once ) { |
| 809 | 809 | require_once( $template_file ); |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | */ |
| 821 | 821 | public function render_widget_hooks( $view_id ) { |
| 822 | 822 | |
| 823 | - if( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
| 823 | + if ( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
| 824 | 824 | do_action( 'gravityview_log_debug', __METHOD__ . ' - Not rendering widgets; single entry' ); |
| 825 | 825 | return; |
| 826 | 826 | } |
@@ -828,9 +828,9 @@ discard block |
||
| 828 | 828 | $view_data = gravityview_get_current_view_data( $view_id ); |
| 829 | 829 | |
| 830 | 830 | // get View widget configuration |
| 831 | - $widgets = (array)$view_data['widgets']; |
|
| 831 | + $widgets = (array)$view_data[ 'widgets' ]; |
|
| 832 | 832 | |
| 833 | - switch( current_filter() ) { |
|
| 833 | + switch ( current_filter() ) { |
|
| 834 | 834 | default: |
| 835 | 835 | case 'gravityview_before': |
| 836 | 836 | $zone = 'header'; |
@@ -844,9 +844,9 @@ discard block |
||
| 844 | 844 | * Filter widgets not in the current zone |
| 845 | 845 | * @since 1.16 |
| 846 | 846 | */ |
| 847 | - foreach( $widgets as $key => $widget ) { |
|
| 847 | + foreach ( $widgets as $key => $widget ) { |
|
| 848 | 848 | // The widget isn't in the current zone |
| 849 | - if( false === strpos( $key, $zone ) ) { |
|
| 849 | + if ( false === strpos( $key, $zone ) ) { |
|
| 850 | 850 | unset( $widgets[ $key ] ); |
| 851 | 851 | } |
| 852 | 852 | } |
@@ -861,8 +861,8 @@ discard block |
||
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | // Prevent being called twice |
| 864 | - if( did_action( $zone.'_'.$view_id.'_widgets' ) ) { |
|
| 865 | - do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__ , $zone.'_'.$view_id.'_widgets' ) ); |
|
| 864 | + if ( did_action( $zone . '_' . $view_id . '_widgets' ) ) { |
|
| 865 | + do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__, $zone . '_' . $view_id . '_widgets' ) ); |
|
| 866 | 866 | return; |
| 867 | 867 | } |
| 868 | 868 | |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | |
| 874 | 874 | $default_css_class = 'gv-grid gv-widgets-' . $zone; |
| 875 | 875 | |
| 876 | - if( 0 === GravityView_View::getInstance()->getTotalEntries() ) { |
|
| 876 | + if ( 0 === GravityView_View::getInstance()->getTotalEntries() ) { |
|
| 877 | 877 | $default_css_class .= ' gv-widgets-no-results'; |
| 878 | 878 | } |
| 879 | 879 | |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | * @param string $zone Current widget zone, either `header` or `footer` |
| 885 | 885 | * @param array $widgets Array of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']` |
| 886 | 886 | */ |
| 887 | - $css_class = apply_filters('gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets ); |
|
| 887 | + $css_class = apply_filters( 'gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets ); |
|
| 888 | 888 | |
| 889 | 889 | $css_class = gravityview_sanitize_html_class( $css_class ); |
| 890 | 890 | |
@@ -892,17 +892,17 @@ discard block |
||
| 892 | 892 | ?> |
| 893 | 893 | <div class="<?php echo $css_class; ?>"> |
| 894 | 894 | <?php |
| 895 | - foreach( $rows as $row ) { |
|
| 896 | - foreach( $row as $col => $areas ) { |
|
| 897 | - $column = ($col == '2-2') ? '1-2 gv-right' : $col.' gv-left'; |
|
| 895 | + foreach ( $rows as $row ) { |
|
| 896 | + foreach ( $row as $col => $areas ) { |
|
| 897 | + $column = ( $col == '2-2' ) ? '1-2 gv-right' : $col . ' gv-left'; |
|
| 898 | 898 | ?> |
| 899 | 899 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
| 900 | 900 | <?php |
| 901 | - if( !empty( $areas ) ) { |
|
| 902 | - foreach( $areas as $area ) { |
|
| 903 | - if( !empty( $widgets[ $zone .'_'. $area['areaid'] ] ) ) { |
|
| 904 | - foreach( $widgets[ $zone .'_'. $area['areaid'] ] as $widget ) { |
|
| 905 | - do_action( "gravityview_render_widget_{$widget['id']}", $widget ); |
|
| 901 | + if ( ! empty( $areas ) ) { |
|
| 902 | + foreach ( $areas as $area ) { |
|
| 903 | + if ( ! empty( $widgets[ $zone . '_' . $area[ 'areaid' ] ] ) ) { |
|
| 904 | + foreach ( $widgets[ $zone . '_' . $area[ 'areaid' ] ] as $widget ) { |
|
| 905 | + do_action( "gravityview_render_widget_{$widget[ 'id' ]}", $widget ); |
|
| 906 | 906 | } |
| 907 | 907 | } |
| 908 | 908 | } |
@@ -918,8 +918,8 @@ discard block |
||
| 918 | 918 | * Prevent widgets from being called twice. |
| 919 | 919 | * Checking for loop_start prevents themes and plugins that pre-process shortcodes from triggering the action before displaying. Like, ahem, the Divi theme and WordPress SEO plugin |
| 920 | 920 | */ |
| 921 | - if( did_action( 'wp_head' ) ) { |
|
| 922 | - do_action( $zone.'_'.$view_id.'_widgets' ); |
|
| 921 | + if ( did_action( 'wp_head' ) ) { |
|
| 922 | + do_action( $zone . '_' . $view_id . '_widgets' ); |
|
| 923 | 923 | } |
| 924 | 924 | } |
| 925 | 925 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | if ( 'address' === rgar( $search_field, 'type' ) ) { |
| 56 | 56 | |
| 57 | - $field_id = intval( floor( $search_field['key'] ) ); |
|
| 58 | - $input_id = gravityview_get_input_id_from_id( $search_field['key'] ); |
|
| 57 | + $field_id = intval( floor( $search_field[ 'key' ] ) ); |
|
| 58 | + $input_id = gravityview_get_input_id_from_id( $search_field[ 'key' ] ); |
|
| 59 | 59 | $form = GravityView_View::getInstance()->getForm(); |
| 60 | 60 | |
| 61 | 61 | /** @var GF_Field_Address $address_field */ |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $choices = array(); |
| 65 | 65 | |
| 66 | 66 | $method_name = 'get_choices_' . self::get_input_type_from_input_id( $input_id ); |
| 67 | - if( method_exists( $this, $method_name ) ) { |
|
| 67 | + if ( method_exists( $this, $method_name ) ) { |
|
| 68 | 68 | /** |
| 69 | 69 | * @uses GravityView_Field_Address::get_choices_country() |
| 70 | 70 | * @uses GravityView_Field_Address::get_choices_state() |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | $choices = $this->{$method_name}( $address_field ); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if( ! empty( $choices ) ) { |
|
| 76 | - $search_field['choices'] = $choices; |
|
| 77 | - $search_field['type'] = rgar( $search_field, 'input'); |
|
| 75 | + if ( ! empty( $choices ) ) { |
|
| 76 | + $search_field[ 'choices' ] = $choices; |
|
| 77 | + $search_field[ 'type' ] = rgar( $search_field, 'input' ); |
|
| 78 | 78 | } else { |
| 79 | - $search_field['type'] = 'text'; |
|
| 80 | - $search_field['input'] = 'input_text'; |
|
| 79 | + $search_field[ 'type' ] = 'text'; |
|
| 80 | + $search_field[ 'input' ] = 'input_text'; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $country_choices = array(); |
| 104 | 104 | |
| 105 | 105 | foreach ( $countries as $key => $country ) { |
| 106 | - $country_choices[] = array( |
|
| 106 | + $country_choices[ ] = array( |
|
| 107 | 107 | 'value' => $country, |
| 108 | 108 | 'text' => $country, |
| 109 | 109 | ); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | private function get_choices_state( $address_field ) { |
| 129 | 129 | |
| 130 | - $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form['id'] ) : $address_field->addressType; |
|
| 130 | + $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form[ 'id' ] ) : $address_field->addressType; |
|
| 131 | 131 | |
| 132 | 132 | $state_choices = array(); |
| 133 | 133 | |
@@ -139,19 +139,19 @@ discard block |
||
| 139 | 139 | $states = GFCommon::get_canadian_provinces(); |
| 140 | 140 | break; |
| 141 | 141 | default: |
| 142 | - $states = empty( $address_types[ $address_type ]['states'] ) ? array() : $address_types[ $address_type ]['states']; |
|
| 142 | + $states = empty( $address_types[ $address_type ][ 'states' ] ) ? array() : $address_types[ $address_type ][ 'states' ]; |
|
| 143 | 143 | break; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | foreach ( $states as $key => $state ) { |
| 147 | 147 | |
| 148 | - if( 'us' === $address_type ) { |
|
| 148 | + if ( 'us' === $address_type ) { |
|
| 149 | 149 | $value = GFCommon::get_us_state_code( $state ); |
| 150 | 150 | } else { |
| 151 | 151 | $value = $state; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $state_choices[] = array( |
|
| 154 | + $state_choices[ ] = array( |
|
| 155 | 155 | 'value' => $value, |
| 156 | 156 | 'text' => $state, |
| 157 | 157 | ); |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | // Use the same inputs as the "text" input type allows |
| 175 | 175 | $text_inputs = rgar( $input_types, 'text' ); |
| 176 | 176 | |
| 177 | - $input_types['street'] = $text_inputs; |
|
| 178 | - $input_types['street2'] = $text_inputs; |
|
| 179 | - $input_types['city'] = $text_inputs; |
|
| 177 | + $input_types[ 'street' ] = $text_inputs; |
|
| 178 | + $input_types[ 'street2' ] = $text_inputs; |
|
| 179 | + $input_types[ 'city' ] = $text_inputs; |
|
| 180 | 180 | |
| 181 | - $input_types['state'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 182 | - $input_types['zip'] = array( 'input_text' ); |
|
| 183 | - $input_types['country'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 181 | + $input_types[ 'state' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 182 | + $input_types[ 'zip' ] = array( 'input_text' ); |
|
| 183 | + $input_types[ 'country' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 184 | 184 | |
| 185 | 185 | return $input_types; |
| 186 | 186 | } |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | // Is this search field for an input (eg: 4.2) or the whole address field (eg: 4)? |
| 202 | 202 | $input_id = gravityview_get_input_id_from_id( $field_id ); |
| 203 | 203 | |
| 204 | - if( 'address' === $field_type && $input_id ) { |
|
| 204 | + if ( 'address' === $field_type && $input_id ) { |
|
| 205 | 205 | |
| 206 | 206 | // If the input ID matches an expected address input, set to that. Otherwise, keep existing input type. |
| 207 | - if( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
| 207 | + if ( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
| 208 | 208 | $input_type = $address_field_name; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -253,20 +253,20 @@ discard block |
||
| 253 | 253 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
| 254 | 254 | |
| 255 | 255 | // If this is NOT the full address field, return default options. |
| 256 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 256 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 257 | 257 | return $field_options; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if( 'edit' === $context ) { |
|
| 260 | + if ( 'edit' === $context ) { |
|
| 261 | 261 | return $field_options; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | $add_options = array(); |
| 265 | 265 | |
| 266 | - $add_options['show_map_link'] = array( |
|
| 266 | + $add_options[ 'show_map_link' ] = array( |
|
| 267 | 267 | 'type' => 'checkbox', |
| 268 | 268 | 'label' => __( 'Show Map Link:', 'gravityview' ), |
| 269 | - 'desc' => __('Display a "Map It" link below the address', 'gravityview'), |
|
| 269 | + 'desc' => __( 'Display a "Map It" link below the address', 'gravityview' ), |
|
| 270 | 270 | 'value' => true, |
| 271 | 271 | 'merge_tags' => false, |
| 272 | 272 | ); |