@@ -128,10 +128,10 @@ |
||
| 128 | 128 | */ |
| 129 | 129 | public function is_edit_entry( $form_id = 0 ) { |
| 130 | 130 | /** |
| 131 | - * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n |
|
| 132 | - * The Edit Entry functionality overrides this value. |
|
| 133 | - * @param boolean $is_edit_entry |
|
| 134 | - */ |
|
| 131 | + * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n |
|
| 132 | + * The Edit Entry functionality overrides this value. |
|
| 133 | + * @param boolean $is_edit_entry |
|
| 134 | + */ |
|
| 135 | 135 | if ( ( $entry = $this->is_entry( $form_id ) ) && apply_filters( 'gravityview_is_edit_entry', false ) ) { |
| 136 | 136 | return $entry; |
| 137 | 137 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $supports = array( 'title', 'revisions' ); |
| 109 | 109 | |
| 110 | 110 | if ( $is_hierarchical ) { |
| 111 | - $supports[] = 'page-attributes'; |
|
| 111 | + $supports[ ] = 'page-attributes'; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | $rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
| 211 | 211 | |
| 212 | 212 | add_filter( 'query_vars', function( $query_vars ) { |
| 213 | - $query_vars[] = 'csv'; |
|
| 213 | + $query_vars[ ] = 'csv'; |
|
| 214 | 214 | return $query_vars; |
| 215 | 215 | } ); |
| 216 | 216 | |
| 217 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) { |
|
| 217 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) { |
|
| 218 | 218 | call_user_func_array( 'add_rewrite_rule', $rule ); |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -283,13 +283,13 @@ discard block |
||
| 283 | 283 | return $content; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
| 286 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Editing a single entry. |
| 290 | 290 | */ |
| 291 | 291 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
| 292 | - if ( $entry['status'] != 'active' ) { |
|
| 292 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 293 | 293 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 294 | 294 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 295 | 295 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 303 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 303 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 304 | 304 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 305 | 305 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 306 | 306 | } |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * Viewing a single entry. |
| 314 | 314 | */ |
| 315 | 315 | } else if ( $entry = $request->is_entry( $view->form ? $view->form->ID : 0 ) ) { |
| 316 | - if ( $entry['status'] != 'active' ) { |
|
| 316 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 317 | 317 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 318 | 318 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 319 | 319 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 327 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 327 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 328 | 328 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 329 | 329 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 330 | 330 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | $error = \GVCommon::check_entry_display( $entry->as_entry(), $view ); |
| 334 | 334 | |
| 335 | - if( is_wp_error( $error ) ) { |
|
| 335 | + if ( is_wp_error( $error ) ) { |
|
| 336 | 336 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) ); |
| 337 | 337 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 338 | 338 | } |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column ); |
| 502 | 502 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column ); |
| 503 | 503 | |
| 504 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
| 504 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | return $joins; |
@@ -543,10 +543,10 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | list( $join, $join_column, $join_on, $join_on_column ) = $meta; |
| 545 | 545 | |
| 546 | - $forms_ids [] = GF_Form::by_id( $join_on ); |
|
| 546 | + $forms_ids [ ] = GF_Form::by_id( $join_on ); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - return ( !empty( $forms_ids) ) ? $forms_ids : null; |
|
| 549 | + return ( ! empty( $forms_ids ) ) ? $forms_ids : null; |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | if ( ! $view->form ) { |
| 585 | 585 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
| 586 | 586 | 'view_id' => $view->ID, |
| 587 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
| 587 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
| 588 | 588 | ) ); |
| 589 | 589 | } |
| 590 | 590 | |
@@ -817,28 +817,27 @@ discard block |
||
| 817 | 817 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
| 818 | 818 | */ |
| 819 | 819 | $parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
| 820 | - $parameters['context_view_id'] = $this->ID; |
|
| 820 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
| 821 | 821 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
| 822 | 822 | |
| 823 | 823 | if ( $request instanceof REST\Request ) { |
| 824 | 824 | $atts = $this->settings->as_atts(); |
| 825 | 825 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
| 826 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
| 826 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
| 827 | 827 | ) ); |
| 828 | - $parameters['paging'] = $paging_parameters['paging']; |
|
| 828 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
| 832 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
| 831 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
| 833 | 832 | |
| 834 | 833 | if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) { |
| 835 | 834 | /** |
| 836 | 835 | * New \GF_Query stuff :) |
| 837 | 836 | */ |
| 838 | - $query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
| 837 | + $query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
| 839 | 838 | |
| 840 | - $query->limit( $parameters['paging']['page_size'] ) |
|
| 841 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
| 839 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
| 840 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
| 842 | 841 | |
| 843 | 842 | /** |
| 844 | 843 | * Any joins? |
@@ -878,15 +877,15 @@ discard block |
||
| 878 | 877 | } ); |
| 879 | 878 | } else { |
| 880 | 879 | $entries = $this->form->entries |
| 881 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
| 880 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
| 882 | 881 | ->offset( $this->settings->get( 'offset' ) ) |
| 883 | - ->limit( $parameters['paging']['page_size'] ) |
|
| 882 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
| 884 | 883 | ->page( $page ); |
| 885 | 884 | |
| 886 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
| 885 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
| 887 | 886 | $field = new \GV\Field(); |
| 888 | - $field->ID = $parameters['sorting']['key']; |
|
| 889 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
| 887 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
| 888 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
| 890 | 889 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
| 891 | 890 | } |
| 892 | 891 | } |
@@ -40,8 +40,7 @@ discard block |
||
| 40 | 40 | $tab = __( 'Edit Entry', 'gravityview' ); |
| 41 | 41 | $context = 'edit'; |
| 42 | 42 | break; |
| 43 | - case ( $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ): |
|
| 44 | - $tab = __( 'Single Entry', 'gravityview' ); |
|
| 43 | + case ( $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ) : $tab = __( 'Single Entry', 'gravityview' ); |
|
| 45 | 44 | $context = 'single'; |
| 46 | 45 | break; |
| 47 | 46 | default: |
@@ -61,7 +60,7 @@ discard block |
||
| 61 | 60 | $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
| 62 | 61 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
| 63 | 62 | |
| 64 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
| 63 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
| 65 | 64 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
| 66 | 65 | |
| 67 | 66 | echo \GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $gravityview->view->ID ); |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | 'detail' => null, |
| 42 | 42 | ) ); |
| 43 | 43 | |
| 44 | - if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) { |
|
| 45 | - if ( $atts['detail'] && $view = $request->is_view() ) { |
|
| 44 | + if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) { |
|
| 45 | + if ( $atts[ 'detail' ] && $view = $request->is_view() ) { |
|
| 46 | 46 | $view_id = $view->ID; |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -111,12 +111,12 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
| 114 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * View details. |
| 118 | 118 | */ |
| 119 | - if ( $atts['detail'] ) { |
|
| 119 | + if ( $atts[ 'detail' ] ) { |
|
| 120 | 120 | $entries = $view->get_entries( $request ); |
| 121 | 121 | return self::_return( $this->detail( $view, $entries, $atts ) ); |
| 122 | 122 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | return self::_return( '' ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( $entry['status'] != 'active' ) { |
|
| 136 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 137 | 137 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 138 | 138 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 139 | 139 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 147 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 147 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 148 | 148 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 149 | 149 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 150 | 150 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | return self::_return( '' ); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( $entry['status'] != 'active' ) { |
|
| 167 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 168 | 168 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 169 | 169 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 170 | 170 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 178 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 178 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 179 | 179 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 180 | 180 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 181 | 181 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $error = \GVCommon::check_entry_display( $entry->as_entry(), $view ); |
| 185 | 185 | |
| 186 | - if( is_wp_error( $error ) ) { |
|
| 186 | + if ( is_wp_error( $error ) ) { |
|
| 187 | 187 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) ); |
| 188 | 188 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 189 | 189 | } |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | // Mock the request with the actual View, not the global one |
| 201 | 201 | $mock_request = new \GV\Mock_Request(); |
| 202 | - $mock_request->returns['is_view'] = $view; |
|
| 203 | - $mock_request->returns['is_entry'] = $request->is_entry( $view->form ? $view->form->ID : 0 ); |
|
| 204 | - $mock_request->returns['is_edit_entry'] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ); |
|
| 205 | - $mock_request->returns['is_search'] = $request->is_search(); |
|
| 202 | + $mock_request->returns[ 'is_view' ] = $view; |
|
| 203 | + $mock_request->returns[ 'is_entry' ] = $request->is_entry( $view->form ? $view->form->ID : 0 ); |
|
| 204 | + $mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ); |
|
| 205 | + $mock_request->returns[ 'is_search' ] = $request->is_search(); |
|
| 206 | 206 | |
| 207 | 207 | $request = $mock_request; |
| 208 | 208 | } |
@@ -238,16 +238,16 @@ discard block |
||
| 238 | 238 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
| 239 | 239 | |
| 240 | 240 | // Only keep the passed attributes after making sure that they're valid pairs |
| 241 | - $filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
| 241 | + $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts ); |
|
| 242 | 242 | |
| 243 | 243 | $atts = array(); |
| 244 | 244 | |
| 245 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
| 245 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
| 246 | 246 | |
| 247 | 247 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
| 248 | 248 | $passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value ); |
| 249 | 249 | |
| 250 | - switch( $defaults[ $key ]['type'] ) { |
|
| 250 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | 253 | * Make sure number fields are numeric. |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
| 256 | 256 | */ |
| 257 | 257 | case 'number': |
| 258 | - if( is_numeric( $passed_value ) ) { |
|
| 258 | + if ( is_numeric( $passed_value ) ) { |
|
| 259 | 259 | $atts[ $key ] = ( $passed_value + 0 ); |
| 260 | 260 | } |
| 261 | 261 | break; |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | case 'select': |
| 272 | 272 | case 'radio': |
| 273 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
| 274 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 273 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
| 274 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 275 | 275 | $atts[ $key ] = $passed_value; |
| 276 | 276 | } |
| 277 | 277 | break; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
| 286 | + $atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
| 287 | 287 | |
| 288 | 288 | return $atts; |
| 289 | 289 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | private function detail( $view, $entries, $atts ) { |
| 301 | 301 | $output = ''; |
| 302 | 302 | |
| 303 | - switch ( $key = $atts['detail'] ): |
|
| 303 | + switch ( $key = $atts[ 'detail' ] ): |
|
| 304 | 304 | case 'total_entries': |
| 305 | 305 | $output = number_format_i18n( $entries->total() ); |
| 306 | 306 | break; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | 'type' => 'radio', |
| 65 | 65 | 'full_width' => true, |
| 66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
| 67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
| 67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
| 68 | 68 | 'value' => 'any', |
| 69 | 69 | 'class' => 'hide-if-js', |
| 70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
| 88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
| 89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
| 89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
| 91 | 91 | |
| 92 | 92 | // ajax - get the searchable fields |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 225 | 225 | $script_source = empty( $script_min ) ? '/source' : ''; |
| 226 | 226 | |
| 227 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
| 227 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
| 228 | 228 | |
| 229 | 229 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
| 230 | 230 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
| 247 | 247 | */ |
| 248 | 248 | public function register_no_conflict( $allowed ) { |
| 249 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
| 249 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
| 250 | 250 | return $allowed; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -259,24 +259,24 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public static function get_searchable_fields() { |
| 261 | 261 | |
| 262 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 262 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 263 | 263 | exit( '0' ); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $form = ''; |
| 267 | 267 | |
| 268 | 268 | // Fetch the form for the current View |
| 269 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 269 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
| 270 | 270 | |
| 271 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 271 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 272 | 272 | |
| 273 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 273 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
| 274 | 274 | |
| 275 | - $form = (int) $_POST['formid']; |
|
| 275 | + $form = (int)$_POST[ 'formid' ]; |
|
| 276 | 276 | |
| 277 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 277 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 278 | 278 | |
| 279 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 279 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | ), |
| 326 | 326 | ); |
| 327 | 327 | |
| 328 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 329 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
| 328 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 329 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Get fields with sub-inputs and no parent |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | foreach ( $fields as $id => $field ) { |
| 350 | 350 | |
| 351 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 351 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 352 | 352 | continue; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 355 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
| 356 | 356 | |
| 357 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 357 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
| 378 | 378 | |
| 379 | 379 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 380 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 380 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 381 | 381 | $input_type = 'boolean'; // on/off checkbox |
| 382 | 382 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 383 | 383 | $input_type = 'multi'; //multiselect |
@@ -421,19 +421,19 @@ discard block |
||
| 421 | 421 | $post_id = 0; |
| 422 | 422 | |
| 423 | 423 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 424 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 425 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 424 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 425 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 426 | 426 | } |
| 427 | 427 | // We're in the WordPress Widget context, and the base View ID should be used |
| 428 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 429 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 428 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 429 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 433 | 433 | |
| 434 | 434 | // Add hidden fields to the search form |
| 435 | 435 | foreach ( $args as $key => $value ) { |
| 436 | - $search_fields[] = array( |
|
| 436 | + $search_fields[ ] = array( |
|
| 437 | 437 | 'name' => $key, |
| 438 | 438 | 'input' => 'hidden', |
| 439 | 439 | 'value' => $value, |
@@ -472,22 +472,22 @@ discard block |
||
| 472 | 472 | /** |
| 473 | 473 | * Include the sidebar Widgets. |
| 474 | 474 | */ |
| 475 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
| 475 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
| 476 | 476 | |
| 477 | 477 | foreach ( $widgets as $widget ) { |
| 478 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
| 479 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
| 478 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
| 479 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
| 480 | 480 | foreach ( $_fields as $field ) { |
| 481 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
| 481 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
| 488 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 488 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 489 | 489 | foreach ( $_fields as $field ) { |
| 490 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
| 490 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | 493 | } |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | public function filter_entries( $search_criteria, $form_id = null, $args = array() ) { |
| 506 | 506 | |
| 507 | - if( 'post' === $this->search_method ) { |
|
| 507 | + if ( 'post' === $this->search_method ) { |
|
| 508 | 508 | $get = $_POST; |
| 509 | 509 | } else { |
| 510 | 510 | $get = $_GET; |
@@ -523,14 +523,14 @@ discard block |
||
| 523 | 523 | $get = gv_map_deep( $get, 'rawurldecode' ); |
| 524 | 524 | |
| 525 | 525 | // Make sure array key is set up |
| 526 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 526 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 527 | 527 | |
| 528 | 528 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
| 529 | 529 | |
| 530 | 530 | // add free search |
| 531 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 531 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 532 | 532 | |
| 533 | - $search_all_value = trim( $get['gv_search'] ); |
|
| 533 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | 536 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | foreach ( $words as $word ) { |
| 558 | - $search_criteria['field_filters'][] = array( |
|
| 558 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 559 | 559 | 'key' => null, // The field ID to search |
| 560 | 560 | 'value' => $word, // The value to search |
| 561 | 561 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -568,11 +568,11 @@ discard block |
||
| 568 | 568 | /** |
| 569 | 569 | * Get and normalize the dates according to the input format. |
| 570 | 570 | */ |
| 571 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
| 571 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
| 572 | 572 | $curr_start = date_create_from_format( $this->get_datepicker_format( true ), $curr_start )->format( 'Y-m-d' ); |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
| 575 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
| 576 | 576 | $curr_end = date_create_from_format( $this->get_datepicker_format( true ), $curr_end )->format( 'Y-m-d' ); |
| 577 | 577 | } |
| 578 | 578 | |
@@ -606,22 +606,22 @@ discard block |
||
| 606 | 606 | */ |
| 607 | 607 | if ( ! empty( $curr_start ) ) { |
| 608 | 608 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
| 609 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 609 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | if ( ! empty( $curr_end ) ) { |
| 613 | 613 | // Fast-forward 24 hour on the end time |
| 614 | 614 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
| 615 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 616 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 617 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
| 615 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 616 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 617 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | // search for a specific entry ID |
| 623 | 623 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
| 624 | - $search_criteria['field_filters'][] = array( |
|
| 624 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 625 | 625 | 'key' => 'id', |
| 626 | 626 | 'value' => absint( $get[ 'gv_id' ] ), |
| 627 | 627 | 'operator' => '=', |
@@ -630,42 +630,42 @@ discard block |
||
| 630 | 630 | |
| 631 | 631 | // search for a specific Created_by ID |
| 632 | 632 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
| 633 | - $search_criteria['field_filters'][] = array( |
|
| 633 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 634 | 634 | 'key' => 'created_by', |
| 635 | - 'value' => absint( $get['gv_by'] ), |
|
| 635 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
| 636 | 636 | 'operator' => '=', |
| 637 | 637 | ); |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | |
| 641 | 641 | // Get search mode passed in URL |
| 642 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 642 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 643 | 643 | |
| 644 | 644 | // get the other search filters |
| 645 | 645 | foreach ( $get as $key => $value ) { |
| 646 | 646 | |
| 647 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
| 647 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
| 648 | 648 | continue; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
| 652 | 652 | |
| 653 | 653 | // could return simple filter or multiple filters |
| 654 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
| 654 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
| 655 | 655 | continue; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
| 659 | 659 | |
| 660 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 661 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 660 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 661 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 662 | 662 | |
| 663 | 663 | // if date range type, set search mode to ALL |
| 664 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 664 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 665 | 665 | $mode = 'all'; |
| 666 | 666 | } |
| 667 | - } elseif( !empty( $filter ) ) { |
|
| 668 | - $search_criteria['field_filters'][] = $filter; |
|
| 667 | + } elseif ( ! empty( $filter ) ) { |
|
| 668 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | * @since 1.5.1 |
| 675 | 675 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 676 | 676 | */ |
| 677 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 677 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 678 | 678 | |
| 679 | 679 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
| 680 | 680 | |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | $field_id = str_replace( 'filter_', '', $key ); |
| 703 | 703 | |
| 704 | 704 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 705 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
| 705 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
| 706 | 706 | $field_id = str_replace( '_', '.', $field_id ); |
| 707 | 707 | } |
| 708 | 708 | |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | |
| 738 | 738 | case 'select': |
| 739 | 739 | case 'radio': |
| 740 | - $filter['operator'] = 'is'; |
|
| 740 | + $filter[ 'operator' ] = 'is'; |
|
| 741 | 741 | break; |
| 742 | 742 | |
| 743 | 743 | case 'post_category': |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | |
| 752 | 752 | foreach ( $value as $val ) { |
| 753 | 753 | $cat = get_term( $val, 'category' ); |
| 754 | - $filter[] = array( |
|
| 754 | + $filter[ ] = array( |
|
| 755 | 755 | 'key' => $filter_key, |
| 756 | 756 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 757 | 757 | 'operator' => 'is', |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | $filter = array(); |
| 771 | 771 | |
| 772 | 772 | foreach ( $value as $val ) { |
| 773 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
| 773 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | break; |
@@ -779,9 +779,9 @@ discard block |
||
| 779 | 779 | // convert checkbox on/off into the correct search filter |
| 780 | 780 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
| 781 | 781 | foreach ( $form_field->inputs as $k => $input ) { |
| 782 | - if ( $input['id'] == $filter_key ) { |
|
| 783 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
| 784 | - $filter['operator'] = 'is'; |
|
| 782 | + if ( $input[ 'id' ] == $filter_key ) { |
|
| 783 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
| 784 | + $filter[ 'operator' ] = 'is'; |
|
| 785 | 785 | break; |
| 786 | 786 | } |
| 787 | 787 | } |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | $filter = array(); |
| 792 | 792 | |
| 793 | 793 | foreach ( $value as $val ) { |
| 794 | - $filter[] = array( |
|
| 794 | + $filter[ ] = array( |
|
| 795 | 795 | 'key' => $filter_key, |
| 796 | 796 | 'value' => $val, |
| 797 | 797 | 'operator' => 'is', |
@@ -812,9 +812,9 @@ discard block |
||
| 812 | 812 | foreach ( $words as $word ) { |
| 813 | 813 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 814 | 814 | // Keep the same key for each filter |
| 815 | - $filter['value'] = $word; |
|
| 815 | + $filter[ 'value' ] = $word; |
|
| 816 | 816 | // Add a search for the value |
| 817 | - $filters[] = $filter; |
|
| 817 | + $filters[ ] = $filter; |
|
| 818 | 818 | } |
| 819 | 819 | } |
| 820 | 820 | |
@@ -828,19 +828,19 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | foreach ( $searchable_fields as $searchable_field ) { |
| 830 | 830 | |
| 831 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
| 831 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
| 832 | 832 | continue; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | // Only exact-match dropdowns, not text search |
| 836 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
| 836 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
| 837 | 837 | continue; |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
| 841 | 841 | |
| 842 | 842 | if ( 4 === $input_id ) { |
| 843 | - $filter['operator'] = 'is'; |
|
| 843 | + $filter[ 'operator' ] = 'is'; |
|
| 844 | 844 | }; |
| 845 | 845 | } |
| 846 | 846 | } |
@@ -865,19 +865,19 @@ discard block |
||
| 865 | 865 | * @since 1.16.3 |
| 866 | 866 | * Safeguard until GF implements '<=' operator |
| 867 | 867 | */ |
| 868 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 868 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 869 | 869 | $operator = '<'; |
| 870 | 870 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - $filter[] = array( |
|
| 873 | + $filter[ ] = array( |
|
| 874 | 874 | 'key' => $filter_key, |
| 875 | 875 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
| 876 | 876 | 'operator' => $operator, |
| 877 | 877 | ); |
| 878 | 878 | } |
| 879 | 879 | } else { |
| 880 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 880 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | break; |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | 'ymd_dot' => 'Y.m.d', |
| 909 | 909 | ); |
| 910 | 910 | |
| 911 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 911 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 912 | 912 | $format = $datepicker[ $field->dateFormat ]; |
| 913 | 913 | } |
| 914 | 914 | |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | public function add_template_path( $file_paths ) { |
| 940 | 940 | |
| 941 | 941 | // Index 100 is the default GravityView template path. |
| 942 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 942 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 943 | 943 | |
| 944 | 944 | return $file_paths; |
| 945 | 945 | } |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | $has_date = false; |
| 959 | 959 | |
| 960 | 960 | foreach ( $search_fields as $k => $field ) { |
| 961 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 961 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 962 | 962 | $has_date = true; |
| 963 | 963 | break; |
| 964 | 964 | } |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | // get configured search fields |
| 988 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 988 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 989 | 989 | |
| 990 | 990 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 991 | 991 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1000,34 +1000,34 @@ discard block |
||
| 1000 | 1000 | |
| 1001 | 1001 | $updated_field = $this->get_search_filter_details( $updated_field ); |
| 1002 | 1002 | |
| 1003 | - switch ( $field['field'] ) { |
|
| 1003 | + switch ( $field[ 'field' ] ) { |
|
| 1004 | 1004 | |
| 1005 | 1005 | case 'search_all': |
| 1006 | - $updated_field['key'] = 'search_all'; |
|
| 1007 | - $updated_field['input'] = 'search_all'; |
|
| 1008 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1006 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 1007 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 1008 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1009 | 1009 | break; |
| 1010 | 1010 | |
| 1011 | 1011 | case 'entry_date': |
| 1012 | - $updated_field['key'] = 'entry_date'; |
|
| 1013 | - $updated_field['input'] = 'entry_date'; |
|
| 1014 | - $updated_field['value'] = array( |
|
| 1012 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 1013 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 1014 | + $updated_field[ 'value' ] = array( |
|
| 1015 | 1015 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 1016 | 1016 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 1017 | 1017 | ); |
| 1018 | 1018 | break; |
| 1019 | 1019 | |
| 1020 | 1020 | case 'entry_id': |
| 1021 | - $updated_field['key'] = 'entry_id'; |
|
| 1022 | - $updated_field['input'] = 'entry_id'; |
|
| 1023 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1021 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 1022 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 1023 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1024 | 1024 | break; |
| 1025 | 1025 | |
| 1026 | 1026 | case 'created_by': |
| 1027 | - $updated_field['key'] = 'created_by'; |
|
| 1028 | - $updated_field['name'] = 'gv_by'; |
|
| 1029 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1030 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
| 1027 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 1028 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 1029 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1030 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
| 1031 | 1031 | break; |
| 1032 | 1032 | } |
| 1033 | 1033 | |
@@ -1046,16 +1046,16 @@ discard block |
||
| 1046 | 1046 | */ |
| 1047 | 1047 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
| 1048 | 1048 | |
| 1049 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 1049 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 1050 | 1050 | |
| 1051 | 1051 | /** @since 1.14 */ |
| 1052 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 1052 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 1053 | 1053 | |
| 1054 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 1054 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 1055 | 1055 | |
| 1056 | 1056 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 1057 | 1057 | |
| 1058 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 1058 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 1059 | 1059 | |
| 1060 | 1060 | if ( $this->has_date_field( $search_fields ) ) { |
| 1061 | 1061 | // enqueue datepicker stuff only if needed! |
@@ -1077,10 +1077,10 @@ discard block |
||
| 1077 | 1077 | public static function get_search_class( $custom_class = '' ) { |
| 1078 | 1078 | $gravityview_view = GravityView_View::getInstance(); |
| 1079 | 1079 | |
| 1080 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 1080 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 1081 | 1081 | |
| 1082 | - if ( ! empty( $custom_class ) ) { |
|
| 1083 | - $search_class .= ' '.$custom_class; |
|
| 1082 | + if ( ! empty( $custom_class ) ) { |
|
| 1083 | + $search_class .= ' ' . $custom_class; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | /** |
@@ -1124,9 +1124,9 @@ discard block |
||
| 1124 | 1124 | |
| 1125 | 1125 | if ( ! $label ) { |
| 1126 | 1126 | |
| 1127 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 1127 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 1128 | 1128 | |
| 1129 | - switch( $field['field'] ) { |
|
| 1129 | + switch ( $field[ 'field' ] ) { |
|
| 1130 | 1130 | case 'search_all': |
| 1131 | 1131 | $label = __( 'Search Entries:', 'gravityview' ); |
| 1132 | 1132 | break; |
@@ -1138,10 +1138,10 @@ discard block |
||
| 1138 | 1138 | break; |
| 1139 | 1139 | default: |
| 1140 | 1140 | // If this is a field input, not a field |
| 1141 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 1141 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 1142 | 1142 | |
| 1143 | 1143 | // Get the label for the field in question, which returns an array |
| 1144 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 1144 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 1145 | 1145 | |
| 1146 | 1146 | // Get the item with the `label` key |
| 1147 | 1147 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1180,32 +1180,32 @@ discard block |
||
| 1180 | 1180 | $form = $gravityview_view->getForm(); |
| 1181 | 1181 | |
| 1182 | 1182 | // for advanced field ids (eg, first name / last name ) |
| 1183 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 1183 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 1184 | 1184 | |
| 1185 | 1185 | // get searched value from $_GET/$_POST (string or array) |
| 1186 | 1186 | $value = $this->rgget_or_rgpost( $name ); |
| 1187 | 1187 | |
| 1188 | 1188 | // get form field details |
| 1189 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 1189 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 1190 | 1190 | |
| 1191 | 1191 | $filter = array( |
| 1192 | - 'key' => $field['field'], |
|
| 1192 | + 'key' => $field[ 'field' ], |
|
| 1193 | 1193 | 'name' => $name, |
| 1194 | 1194 | 'label' => self::get_field_label( $field, $form_field ), |
| 1195 | - 'input' => $field['input'], |
|
| 1195 | + 'input' => $field[ 'input' ], |
|
| 1196 | 1196 | 'value' => $value, |
| 1197 | - 'type' => $form_field['type'], |
|
| 1197 | + 'type' => $form_field[ 'type' ], |
|
| 1198 | 1198 | ); |
| 1199 | 1199 | |
| 1200 | 1200 | // collect choices |
| 1201 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 1202 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 1203 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 1204 | - $filter['choices'] = $form_field['choices']; |
|
| 1201 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 1202 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 1203 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 1204 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 1208 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 1207 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 1208 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | return $filter; |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | |
| 1230 | 1230 | $choices = array(); |
| 1231 | 1231 | foreach ( $users as $user ) { |
| 1232 | - $choices[] = array( |
|
| 1232 | + $choices[ ] = array( |
|
| 1233 | 1233 | 'value' => $user->ID, |
| 1234 | 1234 | 'text' => $user->display_name, |
| 1235 | 1235 | ); |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | */ |
| 1285 | 1285 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1286 | 1286 | |
| 1287 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1287 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1288 | 1288 | |
| 1289 | 1289 | return $js_dependencies; |
| 1290 | 1290 | } |
@@ -1328,7 +1328,7 @@ discard block |
||
| 1328 | 1328 | 'isRTL' => is_rtl(), |
| 1329 | 1329 | ), $view_data ); |
| 1330 | 1330 | |
| 1331 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1331 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1332 | 1332 | |
| 1333 | 1333 | return $localizations; |
| 1334 | 1334 | |
@@ -1355,7 +1355,7 @@ discard block |
||
| 1355 | 1355 | * @return void |
| 1356 | 1356 | */ |
| 1357 | 1357 | private function maybe_enqueue_flexibility() { |
| 1358 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1358 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1359 | 1359 | wp_enqueue_script( 'gv-flexibility' ); |
| 1360 | 1360 | } |
| 1361 | 1361 | } |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1378 | 1378 | |
| 1379 | 1379 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1380 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1380 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1381 | 1381 | |
| 1382 | 1382 | /** |
| 1383 | 1383 | * @filter `gravityview_search_datepicker_class` |