@@ -96,18 +96,18 @@ discard block |
||
| 96 | 96 | $paging = \GV\Utils::get( $parameters, 'paging' ); |
| 97 | 97 | } else { |
| 98 | 98 | $entries = $form->entries |
| 99 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $criteria['search_criteria'] ) ) |
|
| 100 | - ->offset( $args['offset'] ) |
|
| 101 | - ->limit( $criteria['paging']['page_size'] ); |
|
| 99 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $criteria[ 'search_criteria' ] ) ) |
|
| 100 | + ->offset( $args[ 'offset' ] ) |
|
| 101 | + ->limit( $criteria[ 'paging' ][ 'page_size' ] ); |
|
| 102 | 102 | |
| 103 | - if ( $criteria['paging']['page_size'] ) { |
|
| 104 | - $entries = $entries->page( ( ( $criteria['paging']['offset'] - $args['offset'] ) / $criteria['paging']['page_size'] ) + 1 ); |
|
| 103 | + if ( $criteria[ 'paging' ][ 'page_size' ] ) { |
|
| 104 | + $entries = $entries->page( ( ( $criteria[ 'paging' ][ 'offset' ] - $args[ 'offset' ] ) / $criteria[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( ! empty( $criteria['sorting'] ) ) { |
|
| 107 | + if ( ! empty( $criteria[ 'sorting' ] ) ) { |
|
| 108 | 108 | $field = new \GV\Field(); |
| 109 | - $field->ID = $criteria['sorting']['key']; |
|
| 110 | - switch( strtolower( $criteria['sorting']['direction'] ) ) { |
|
| 109 | + $field->ID = $criteria[ 'sorting' ][ 'key' ]; |
|
| 110 | + switch ( strtolower( $criteria[ 'sorting' ][ 'direction' ] ) ) { |
|
| 111 | 111 | case 'asc': |
| 112 | 112 | $direction = \GV\Entry_Sort::ASC; |
| 113 | 113 | break; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | break; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - $mode = $criteria['sorting']['is_numeric'] ? \GV\Entry_Sort::NUMERIC : \GV\Entry_Sort::ALPHA; |
|
| 123 | + $mode = $criteria[ 'sorting' ][ 'is_numeric' ] ? \GV\Entry_Sort::NUMERIC : \GV\Entry_Sort::ALPHA; |
|
| 124 | 124 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction, $mode ) ); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -158,16 +158,16 @@ discard block |
||
| 158 | 158 | * @return null|string The value of a field in an entry. |
| 159 | 159 | */ |
| 160 | 160 | function GravityView_API_field_value( $entry, $field_settings, $format ) { |
| 161 | - if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
| 161 | + if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) { |
|
| 162 | 162 | gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) ); |
| 163 | 163 | return null; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) { |
|
| 167 | - $entry = $entry['_multi'][ $field_settings['form_id'] ]; |
|
| 166 | + if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) { |
|
| 167 | + $entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ]; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( empty( $entry['id'] ) || ! $entry = \GV\GF_Entry::by_id( $entry['id'] ) ) { |
|
| 170 | + if ( empty( $entry[ 'id' ] ) || ! $entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) { |
|
| 171 | 171 | gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) ); |
| 172 | 172 | return null; |
| 173 | 173 | } |
@@ -177,18 +177,18 @@ discard block |
||
| 177 | 177 | * |
| 178 | 178 | * Fields with a numeric ID are Gravity Forms ones. |
| 179 | 179 | */ |
| 180 | - $source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;; |
|
| 180 | + $source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; ; |
|
| 181 | 181 | |
| 182 | 182 | /** Initialize the future field. */ |
| 183 | 183 | switch ( $source ): |
| 184 | 184 | /** The Gravity Forms backend. */ |
| 185 | 185 | case \GV\Source::BACKEND_GRAVITYFORMS: |
| 186 | - if ( ! $form = \GV\GF_Form::by_id( $entry['form_id'] ) ) { |
|
| 186 | + if ( ! $form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) { |
|
| 187 | 187 | gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) ); |
| 188 | 188 | return null; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( ! $field = $form::get_field( $form, $field_settings['id'] ) ) { |
|
| 191 | + if ( ! $field = $form::get_field( $form, $field_settings[ 'id' ] ) ) { |
|
| 192 | 192 | return null; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | /** Our internal backend. */ |
| 198 | 198 | case \GV\Source::BACKEND_INTERNAL: |
| 199 | - if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) { |
|
| 199 | + if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) { |
|
| 200 | 200 | return null; |
| 201 | 201 | } |
| 202 | 202 | |
@@ -230,13 +230,13 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | /** A bail condition. */ |
| 232 | 232 | $bail = function( $label, $field_settings, $entry, $force_show_label, $form ) { |
| 233 | - if ( ! empty( $field_settings['show_label'] ) || $force_show_label ) { |
|
| 233 | + if ( ! empty( $field_settings[ 'show_label' ] ) || $force_show_label ) { |
|
| 234 | 234 | |
| 235 | - $label = isset( $field_settings['label'] ) ? $field_settings['label'] : ''; |
|
| 235 | + $label = isset( $field_settings[ 'label' ] ) ? $field_settings[ 'label' ] : ''; |
|
| 236 | 236 | |
| 237 | 237 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
| 238 | - if ( ! empty( $field_settings['custom_label'] ) ) { |
|
| 239 | - $label = \GravityView_API::replace_variables( $field_settings['custom_label'], $form, $entry ); |
|
| 238 | + if ( ! empty( $field_settings[ 'custom_label' ] ) ) { |
|
| 239 | + $label = \GravityView_API::replace_variables( $field_settings[ 'custom_label' ], $form, $entry ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -262,19 +262,19 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | $label = ''; |
| 264 | 264 | |
| 265 | - if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) { |
|
| 266 | - $entry = $entry['_multi'][ $field_settings['form_id'] ]; |
|
| 267 | - if ( $_form = \GV\GF_Form::by_id( $field_settings['form_id'] ) ) { |
|
| 265 | + if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) { |
|
| 266 | + $entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ]; |
|
| 267 | + if ( $_form = \GV\GF_Form::by_id( $field_settings[ 'form_id' ] ) ) { |
|
| 268 | 268 | $form = $_form->form; |
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
| 272 | + if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) { |
|
| 273 | 273 | gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) ); |
| 274 | 274 | return $bail( $label, $field_settings, $entry, $force_show_label, $form ); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - if ( empty( $entry['id'] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry['id'] ) ) { |
|
| 277 | + if ( empty( $entry[ 'id' ] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) { |
|
| 278 | 278 | gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) ); |
| 279 | 279 | return $bail( $label, $field_settings, $entry, $force_show_label, $form ); |
| 280 | 280 | } |
@@ -286,31 +286,31 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * Fields with a numeric ID are Gravity Forms ones. |
| 288 | 288 | */ |
| 289 | - $source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; |
|
| 289 | + $source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; |
|
| 290 | 290 | |
| 291 | 291 | /** Initialize the future field. */ |
| 292 | 292 | switch ( $source ): |
| 293 | 293 | /** The Gravity Forms backend. */ |
| 294 | 294 | case \GV\Source::BACKEND_GRAVITYFORMS: |
| 295 | - if ( ! $gf_form = \GV\GF_Form::by_id( $entry['form_id'] ) ) { |
|
| 295 | + if ( ! $gf_form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) { |
|
| 296 | 296 | gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) ); |
| 297 | 297 | return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form ); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - if ( ! $field = $gf_form::get_field( $gf_form, $field_settings['id'] ) ) { |
|
| 301 | - gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings['id'], 'data' => $form ) ); |
|
| 300 | + if ( ! $field = $gf_form::get_field( $gf_form, $field_settings[ 'id' ] ) ) { |
|
| 301 | + gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings[ 'id' ], 'data' => $form ) ); |
|
| 302 | 302 | return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $gf_form->form ); |
| 303 | 303 | } |
| 304 | - if ( empty( $field_settings['show_label'] ) ) { |
|
| 304 | + if ( empty( $field_settings[ 'show_label' ] ) ) { |
|
| 305 | 305 | /** The label never wins... */ |
| 306 | - $field_settings['label'] = ''; |
|
| 306 | + $field_settings[ 'label' ] = ''; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | break; |
| 310 | 310 | |
| 311 | 311 | /** Our internal backend. */ |
| 312 | 312 | case \GV\Source::BACKEND_INTERNAL: |
| 313 | - if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) { |
|
| 313 | + if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) { |
|
| 314 | 314 | return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form ); |
| 315 | 315 | } |
| 316 | 316 | break; |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | break; |
| 323 | 323 | endswitch; |
| 324 | 324 | |
| 325 | - if( $force_show_label ) { |
|
| 326 | - $field_settings['show_label'] = '1'; |
|
| 325 | + if ( $force_show_label ) { |
|
| 326 | + $field_settings[ 'show_label' ] = '1'; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** Add the field settings. */ |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | '\GravityView_frontend::entry' => \GravityView_frontend::getInstance()->getEntry(), |
| 458 | 458 | '\GravityView_View::_current_entry' => \GravityView_View::getInstance()->getCurrentEntry(), |
| 459 | 459 | '\GravityView_View::fields' => \GravityView_View::getInstance()->getFields(), |
| 460 | - 'wp_actions[loop_start]' => empty( $wp_actions['loop_start'] ) ? 0 : $wp_actions['loop_start'], |
|
| 460 | + 'wp_actions[loop_start]' => empty( $wp_actions[ 'loop_start' ] ) ? 0 : $wp_actions[ 'loop_start' ], |
|
| 461 | 461 | 'wp_query::in_the_loop' => $wp_query->in_the_loop, |
| 462 | 462 | ); |
| 463 | 463 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | break; |
| 540 | 540 | case 'wp_actions[loop_start]': |
| 541 | 541 | global $wp_actions; |
| 542 | - $wp_actions['loop_start'] = $value; |
|
| 542 | + $wp_actions[ 'loop_start' ] = $value; |
|
| 543 | 543 | break; |
| 544 | 544 | case 'wp_query::in_the_loop': |
| 545 | 545 | global $wp_query; |
@@ -617,9 +617,7 @@ discard block |
||
| 617 | 617 | case 'request': |
| 618 | 618 | self::thaw( array( |
| 619 | 619 | '\GravityView_View::context' => ( |
| 620 | - $value->is_entry() ? 'single' : |
|
| 621 | - ( $value->is_edit_entry() ? 'edit' : |
|
| 622 | - ( $value->is_view() ? 'directory': null ) |
|
| 620 | + $value->is_entry() ? 'single' : ( $value->is_edit_entry() ? 'edit' : ( $value->is_view() ? 'directory' : null ) |
|
| 623 | 621 | ) |
| 624 | 622 | ), |
| 625 | 623 | '\GravityView_frontend::is_search' => $value->is_search(), |
@@ -673,14 +671,14 @@ discard block |
||
| 673 | 671 | global $wp_query, $wp_actions; |
| 674 | 672 | |
| 675 | 673 | $wp_query->in_the_loop = false; |
| 676 | - $wp_actions['loop_start'] = 0; |
|
| 674 | + $wp_actions[ 'loop_start' ] = 0; |
|
| 677 | 675 | } |
| 678 | 676 | } |
| 679 | 677 | |
| 680 | 678 | |
| 681 | 679 | /** Add some global fix for field capability discrepancies. */ |
| 682 | 680 | add_filter( 'gravityview/configuration/fields', function( $fields ) { |
| 683 | - if ( empty( $fields ) ) { |
|
| 681 | + if ( empty( $fields ) ) { |
|
| 684 | 682 | return $fields; |
| 685 | 683 | } |
| 686 | 684 | |
@@ -707,11 +705,11 @@ discard block |
||
| 707 | 705 | } |
| 708 | 706 | |
| 709 | 707 | foreach ( $_fields as $uid => &$_field ) { |
| 710 | - if ( ! isset( $_field['only_loggedin'] ) ) { |
|
| 708 | + if ( ! isset( $_field[ 'only_loggedin' ] ) ) { |
|
| 711 | 709 | continue; |
| 712 | 710 | } |
| 713 | 711 | /** If we do not require login, we don't require a cap. */ |
| 714 | - $_field['only_loggedin'] != '1' && ( $_field['only_loggedin_cap'] = '' ); |
|
| 712 | + $_field[ 'only_loggedin' ] != '1' && ( $_field[ 'only_loggedin_cap' ] = '' ); |
|
| 715 | 713 | } |
| 716 | 714 | } |
| 717 | 715 | return $fields; |
@@ -742,8 +740,8 @@ discard block |
||
| 742 | 740 | } |
| 743 | 741 | |
| 744 | 742 | foreach ( $_fields as $uid => &$_field ) { |
| 745 | - if ( ! empty( $_field['id'] ) && is_numeric( $_field['id'] ) && empty( $_field['form_id'] ) ) { |
|
| 746 | - $_field['form_id'] = $view->form->ID; |
|
| 743 | + if ( ! empty( $_field[ 'id' ] ) && is_numeric( $_field[ 'id' ] ) && empty( $_field[ 'form_id' ] ) ) { |
|
| 744 | + $_field[ 'form_id' ] = $view->form->ID; |
|
| 747 | 745 | } |
| 748 | 746 | } |
| 749 | 747 | } |
@@ -757,25 +755,25 @@ discard block |
||
| 757 | 755 | if ( class_exists( '\GravityView_frontend' ) ) { |
| 758 | 756 | global $wp_filter; |
| 759 | 757 | |
| 760 | - if ( empty( $wp_filter['gravityview_after'] ) ) { |
|
| 758 | + if ( empty( $wp_filter[ 'gravityview_after' ] ) ) { |
|
| 761 | 759 | return; |
| 762 | 760 | } |
| 763 | 761 | |
| 764 | 762 | /** WordPress 4.6 and lower compatibility, when WP_Hook classes were still absent. */ |
| 765 | - if ( is_array( $wp_filter['gravityview_after'] ) ) { |
|
| 766 | - if ( ! empty( $wp_filter['gravityview_after'][10] ) ) { |
|
| 767 | - foreach ( $wp_filter['gravityview_after'][10] as $function_key => $callback ) { |
|
| 763 | + if ( is_array( $wp_filter[ 'gravityview_after' ] ) ) { |
|
| 764 | + if ( ! empty( $wp_filter[ 'gravityview_after' ][ 10 ] ) ) { |
|
| 765 | + foreach ( $wp_filter[ 'gravityview_after' ][ 10 ] as $function_key => $callback ) { |
|
| 768 | 766 | if ( strpos( $function_key, 'context_not_configured_warning' ) ) { |
| 769 | - unset( $wp_filter['gravityview_after'][10][ $function_key ] ); |
|
| 767 | + unset( $wp_filter[ 'gravityview_after' ][ 10 ][ $function_key ] ); |
|
| 770 | 768 | } |
| 771 | 769 | } |
| 772 | 770 | } |
| 773 | 771 | return; |
| 774 | 772 | } |
| 775 | 773 | |
| 776 | - foreach ( $wp_filter['gravityview_after']->callbacks[10] as $function_key => $callback ) { |
|
| 774 | + foreach ( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ] as $function_key => $callback ) { |
|
| 777 | 775 | if ( strpos( $function_key, 'context_not_configured_warning' ) ) { |
| 778 | - unset( $wp_filter['gravityview_after']->callbacks[10][ $function_key ] ); |
|
| 776 | + unset( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ][ $function_key ] ); |
|
| 779 | 777 | } |
| 780 | 778 | } |
| 781 | 779 | } |