@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | function render_input( $override_input = null ) { |
25 | - if( isset( $override_input ) ) { |
|
25 | + if ( isset( $override_input ) ) { |
|
26 | 26 | echo $override_input; |
27 | 27 | return; |
28 | 28 | } |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | ?> |
31 | 31 | <ul class="gv-setting-list"> |
32 | 32 | <?php |
33 | - foreach( $this->field['options'] as $value => $label ) { ?> |
|
34 | - <li <?php if( isset( $label['requires'] ) ) { printf( 'class="gv-sub-setting" data-requires="%s"', $label['requires'] ); } ?>> |
|
33 | + foreach ( $this->field[ 'options' ] as $value => $label ) { ?> |
|
34 | + <li <?php if ( isset( $label[ 'requires' ] ) ) { printf( 'class="gv-sub-setting" data-requires="%s"', $label[ 'requires' ] ); } ?>> |
|
35 | 35 | <label> |
36 | 36 | <input name="<?php printf( '%s[%s]', esc_attr( $this->name ), esc_attr( $value ) ); ?>" type="hidden" |
37 | 37 | value="0"/> |
38 | 38 | <input name="<?php printf( '%s[%s]', esc_attr( $this->name ), esc_attr( $value ) ); ?>" |
39 | 39 | id="<?php echo $this->get_field_id(); ?>" type="checkbox" |
40 | 40 | value="1" <?php checked( ! empty( $this->value[ $value ] ) ); ?> /> |
41 | - <?php echo esc_html( $label['label'] ); ?> |
|
41 | + <?php echo esc_html( $label[ 'label' ] ); ?> |
|
42 | 42 | </label> |
43 | - <?php if( ! empty( $label['desc'] ) ) { |
|
44 | - printf( '<span class="howto">%s</span>', $label['desc'] ); |
|
43 | + <?php if ( ! empty( $label[ 'desc' ] ) ) { |
|
44 | + printf( '<span class="howto">%s</span>', $label[ 'desc' ] ); |
|
45 | 45 | } |
46 | 46 | ?> |
47 | 47 | </li> |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | $gravityview_view = GravityView_View::getInstance(); |
10 | 10 | |
11 | 11 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
12 | -$show_notes_logged_out = ( ! empty( $visibility_settings['view'] ) && ! empty( $visibility_settings['view_loggedout'] ) ); |
|
12 | +$show_notes_logged_out = ( ! empty( $visibility_settings[ 'view' ] ) && ! empty( $visibility_settings[ 'view_loggedout' ] ) ); |
|
13 | 13 | |
14 | -if( ! GVCommon::has_cap( array( 'gravityview_view_entry_notes', 'gravityview_add_entry_notes', 'gravityview_delete_entry_notes' ) ) && ! $show_notes_logged_out ) { |
|
14 | +if ( ! GVCommon::has_cap( array( 'gravityview_view_entry_notes', 'gravityview_add_entry_notes', 'gravityview_delete_entry_notes' ) ) && ! $show_notes_logged_out ) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | do_action( 'gravityview/field/notes/scripts' ); |
26 | 26 | |
27 | 27 | $entry = $gravityview_view->getCurrentEntry(); |
28 | -$notes = GravityView_Entry_Notes::get_notes( $entry['id'] ); |
|
28 | +$notes = GravityView_Entry_Notes::get_notes( $entry[ 'id' ] ); |
|
29 | 29 | $strings = GravityView_Field_Notes::strings(); |
30 | -$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
30 | +$entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
31 | 31 | |
32 | -$show_add = ! empty( $visibility_settings['add'] ); |
|
33 | -$show_delete = ( ! empty( $visibility_settings['delete'] ) && GVCommon::has_cap( 'gravityview_delete_entry_notes' ) ); |
|
34 | -$show_notes = $show_notes_logged_out || ( ! empty( $visibility_settings['view'] ) && GVCommon::has_cap( 'gravityview_view_entry_notes' ) ); |
|
32 | +$show_add = ! empty( $visibility_settings[ 'add' ] ); |
|
33 | +$show_delete = ( ! empty( $visibility_settings[ 'delete' ] ) && GVCommon::has_cap( 'gravityview_delete_entry_notes' ) ); |
|
34 | +$show_notes = $show_notes_logged_out || ( ! empty( $visibility_settings[ 'view' ] ) && GVCommon::has_cap( 'gravityview_view_entry_notes' ) ); |
|
35 | 35 | |
36 | 36 | $container_class = ( sizeof( $notes ) > 0 ? 'gv-has-notes' : 'gv-no-notes' ); |
37 | 37 | $container_class .= $show_notes ? ' gv-show-notes' : ' gv-hide-notes'; |
38 | 38 | ?> |
39 | 39 | <div class="gv-notes <?php echo $container_class; ?>"> |
40 | 40 | <?php |
41 | - if( $show_notes ) { |
|
41 | + if ( $show_notes ) { |
|
42 | 42 | ?> |
43 | 43 | <form method="post" class="gv-notes-list"> |
44 | 44 | <?php if ( $show_delete ) { wp_nonce_field( 'gv_delete_notes_' . $entry_slug, 'gv_delete_notes' ); } ?> |
@@ -46,21 +46,21 @@ discard block |
||
46 | 46 | <input type="hidden" name="action" value="gv_delete_notes" /> |
47 | 47 | <input type="hidden" name="entry-slug" value="<?php echo esc_attr( $entry_slug ); ?>" /> |
48 | 48 | <table> |
49 | - <caption><?php echo $strings['caption']; ?></caption> |
|
49 | + <caption><?php echo $strings[ 'caption' ]; ?></caption> |
|
50 | 50 | <?php |
51 | 51 | if ( $show_delete ) { |
52 | 52 | ?> |
53 | 53 | <thead> |
54 | 54 | <tr> |
55 | 55 | <th colspan="2"> |
56 | - <label><input type="checkbox" value="" class="gv-notes-toggle" title="<?php echo $strings['toggle-notes']; ?>"><span class="screen-reader-text"><?php echo $strings['toggle-notes']; ?></span></label> |
|
57 | - <button type="submit" class="button button-small gv-notes-delete"><?php echo $strings['delete']; ?></button> |
|
56 | + <label><input type="checkbox" value="" class="gv-notes-toggle" title="<?php echo $strings[ 'toggle-notes' ]; ?>"><span class="screen-reader-text"><?php echo $strings[ 'toggle-notes' ]; ?></span></label> |
|
57 | + <button type="submit" class="button button-small gv-notes-delete"><?php echo $strings[ 'delete' ]; ?></button> |
|
58 | 58 | </th> |
59 | 59 | </tr> |
60 | 60 | </thead> |
61 | 61 | <?php } ?> |
62 | 62 | <tbody> |
63 | - <tr class="gv-notes-no-notes"><td colspan="2"><?php echo $strings['no-notes']; ?></td></tr> |
|
63 | + <tr class="gv-notes-no-notes"><td colspan="2"><?php echo $strings[ 'no-notes' ]; ?></td></tr> |
|
64 | 64 | <?php |
65 | 65 | foreach ( $notes as $note ) { |
66 | 66 | echo GravityView_Field_Notes::display_note( $note, $show_delete ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | <?php |
74 | 74 | } // End if can view notes |
75 | 75 | |
76 | - if( $show_add ) { |
|
76 | + if ( $show_add ) { |
|
77 | 77 | echo do_shortcode( '[gv_note_add]' ); |
78 | 78 | } |
79 | 79 | ?> |
@@ -50,7 +50,7 @@ |
||
50 | 50 | */ |
51 | 51 | public function if_gravityview_return_true( $has_content = false ) { |
52 | 52 | |
53 | - if( ! class_exists( 'GravityView_frontend' ) ) { |
|
53 | + if ( ! class_exists( 'GravityView_frontend' ) ) { |
|
54 | 54 | return $has_content; |
55 | 55 | } |
56 | 56 |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | // Dequeue other jQuery styles even if no-conflict is off. |
118 | 118 | // Terrible-looking tabs help no one. |
119 | - if( !empty( $wp_styles->registered ) ) { |
|
119 | + if( !empty( $wp_styles->registered ) ) { |
|
120 | 120 | foreach ($wp_styles->registered as $key => $style) { |
121 | 121 | if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
122 | 122 | wp_dequeue_style( $key ); |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | |
190 | 190 | //unregistering scripts |
191 | 191 | $registered = array(); |
192 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
193 | - if( in_array( $handle, $required_objects ) ){ |
|
192 | + foreach( $wp_objects->registered as $handle => $script_registration ) { |
|
193 | + if( in_array( $handle, $required_objects ) ) { |
|
194 | 194 | $registered[ $handle ] = $script_registration; |
195 | 195 | } |
196 | 196 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - if( ! is_admin() ) { return; } |
|
21 | + if ( ! is_admin() ) { return; } |
|
22 | 22 | |
23 | 23 | $this->add_hooks(); |
24 | 24 | } |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private function add_hooks() { |
34 | 34 | //Hooks for no-conflict functionality |
35 | - add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000); |
|
36 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9); |
|
35 | + add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000 ); |
|
36 | + add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9 ); |
|
37 | 37 | |
38 | - add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000); |
|
39 | - add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11); |
|
40 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1); |
|
41 | - add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1); |
|
38 | + add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000 ); |
|
39 | + add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11 ); |
|
40 | + add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1 ); |
|
41 | + add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1 ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | function no_conflict_scripts() { |
52 | 52 | global $wp_scripts; |
53 | 53 | |
54 | - if( ! gravityview_is_admin_page() ) { |
|
54 | + if ( ! gravityview_is_admin_page() ) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $no_conflict_mode = gravityview()->plugin->settings->get( 'no-conflict-mode' ); |
59 | 59 | |
60 | - if( empty( $no_conflict_mode ) ) { |
|
60 | + if ( empty( $no_conflict_mode ) ) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | function no_conflict_styles() { |
111 | 111 | global $wp_styles; |
112 | 112 | |
113 | - if( ! gravityview_is_admin_page() ) { |
|
113 | + if ( ! gravityview_is_admin_page() ) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Dequeue other jQuery styles even if no-conflict is off. |
118 | 118 | // Terrible-looking tabs help no one. |
119 | - if( !empty( $wp_styles->registered ) ) { |
|
120 | - foreach ($wp_styles->registered as $key => $style) { |
|
121 | - if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
119 | + if ( ! empty( $wp_styles->registered ) ) { |
|
120 | + foreach ( $wp_styles->registered as $key => $style ) { |
|
121 | + if ( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
122 | 122 | wp_dequeue_style( $key ); |
123 | 123 | } |
124 | 124 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $no_conflict_mode = gravityview()->plugin->settings->get( 'no-conflict-mode' ); |
128 | 128 | |
129 | 129 | // If no conflict is off, jQuery will suffice. |
130 | - if( empty( $no_conflict_mode ) ) { |
|
130 | + if ( empty( $no_conflict_mode ) ) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here. |
156 | 156 | */ |
157 | - do_action('gravityview_remove_conflicts_after'); |
|
157 | + do_action( 'gravityview_remove_conflicts_after' ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | |
179 | 179 | //reset queue |
180 | 180 | $queue = array(); |
181 | - foreach( $wp_objects->queue as $object ) { |
|
182 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
183 | - $queue[] = $object; |
|
181 | + foreach ( $wp_objects->queue as $object ) { |
|
182 | + if ( in_array( $object, $required_objects ) || preg_match( '/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
183 | + $queue[ ] = $object; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | $wp_objects->queue = $queue; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | |
190 | 190 | //unregistering scripts |
191 | 191 | $registered = array(); |
192 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
193 | - if( in_array( $handle, $required_objects ) ){ |
|
192 | + foreach ( $wp_objects->registered as $handle => $script_registration ) { |
|
193 | + if ( in_array( $handle, $required_objects ) ) { |
|
194 | 194 | $registered[ $handle ] = $script_registration; |
195 | 195 | } |
196 | 196 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param array $registered [description] |
206 | 206 | * @param array $scripts [description] |
207 | 207 | */ |
208 | - private function add_script_dependencies($registered, $scripts) { |
|
208 | + private function add_script_dependencies( $registered, $scripts ) { |
|
209 | 209 | |
210 | 210 | //gets all dependent scripts linked to the $scripts array passed |
211 | 211 | do { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array(); |
215 | 215 | foreach ( $deps as $dep ) { |
216 | 216 | if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) { |
217 | - $dependents[] = $dep; |
|
217 | + $dependents[ ] = $dep; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
@@ -19,12 +19,12 @@ |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | function render_input( $override_input = null ) { |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | - foreach( $this->field['options'] as $value => $label ) : ?> |
|
27 | + foreach ( $this->field[ 'options' ] as $value => $label ) : ?> |
|
28 | 28 | <label class="<?php echo $this->get_label_class(); ?>"> |
29 | 29 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>-<?php echo esc_attr( $value ); ?>" type="radio" value="<?php echo esc_attr( $value ); ?>" <?php checked( $value, $this->value, true ); ?> /> <?php echo esc_html( $label ); ?> |
30 | 30 | </label> |
@@ -38,8 +38,8 @@ |
||
38 | 38 | // Set the $_field_id var |
39 | 39 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
40 | 40 | |
41 | - if( $this->is_choice_value_enabled() ) { |
|
42 | - $field_options['choice_display'] = array( |
|
41 | + if ( $this->is_choice_value_enabled() ) { |
|
42 | + $field_options[ 'choice_display' ] = array( |
|
43 | 43 | 'type' => 'radio', |
44 | 44 | 'value' => 'value', |
45 | 45 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -48,25 +48,25 @@ |
||
48 | 48 | |
49 | 49 | $quiz_fields = GFAPI::get_fields_by_type( $form, 'quiz' ); |
50 | 50 | |
51 | - if( ! empty( $quiz_fields ) ) { |
|
51 | + if ( ! empty( $quiz_fields ) ) { |
|
52 | 52 | |
53 | - $fields['gquiz_score'] = array( |
|
53 | + $fields[ 'gquiz_score' ] = array( |
|
54 | 54 | 'label' => __( 'Quiz Score Total', 'gravityview' ), |
55 | 55 | 'type' => 'quiz_score', |
56 | 56 | 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
57 | 57 | ); |
58 | - $fields['gquiz_percent'] = array( |
|
58 | + $fields[ 'gquiz_percent' ] = array( |
|
59 | 59 | 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
60 | 60 | 'type' => 'quiz_percent', |
61 | 61 | 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
62 | 62 | ); |
63 | - $fields['gquiz_grade'] = array( |
|
63 | + $fields[ 'gquiz_grade' ] = array( |
|
64 | 64 | /* translators: This is a field type used by the Gravity Forms Quiz Addon. "A" is 100-90, "B" is 89-80, "C" is 79-70, etc. */ |
65 | 65 | 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
66 | 66 | 'type' => 'quiz_grade', |
67 | 67 | 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
68 | 68 | ); |
69 | - $fields['gquiz_is_pass'] = array( |
|
69 | + $fields[ 'gquiz_is_pass' ] = array( |
|
70 | 70 | 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
71 | 71 | 'type' => 'quiz_is_pass', |
72 | 72 | 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | 55 | if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | - if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
|
55 | + if ( ! is_numeric( $field[ 'id' ] ) || ! empty( $field[ 'custom_label' ] ) ) { |
|
56 | 56 | return $label; |
57 | 57 | } |
58 | 58 | |
59 | - $field_object = GFFormsModel::get_field( $form, $field['id'] ); |
|
59 | + $field_object = GFFormsModel::get_field( $form, $field[ 'id' ] ); |
|
60 | 60 | |
61 | - if( $field_object && 'password' === $field_object->type ) { |
|
62 | - $label = $field['label']; |
|
61 | + if ( $field_object && 'password' === $field_object->type ) { |
|
62 | + $label = $field[ 'label' ]; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $label; |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | function add_form_fields( $fields = array(), $form = array(), $include_parent_field = true ) { |
80 | 80 | |
81 | 81 | foreach ( $fields as $key => $field ) { |
82 | - if( 'password' === $field['type'] ) { |
|
82 | + if ( 'password' === $field[ 'type' ] ) { |
|
83 | 83 | |
84 | 84 | // The Enter Password input |
85 | - if( floor( $key ) === floatval( $key ) ) { |
|
85 | + if ( floor( $key ) === floatval( $key ) ) { |
|
86 | 86 | |
87 | - if( ! empty( $field['parent'] ) ) { |
|
88 | - $field['label'] = $field['parent']->label; |
|
89 | - $field['adminOnly'] = $field['parent']->adminOnly; |
|
90 | - $field['adminLabel'] = $field['parent']->adminLabel; |
|
87 | + if ( ! empty( $field[ 'parent' ] ) ) { |
|
88 | + $field[ 'label' ] = $field[ 'parent' ]->label; |
|
89 | + $field[ 'adminOnly' ] = $field[ 'parent' ]->adminOnly; |
|
90 | + $field[ 'adminLabel' ] = $field[ 'parent' ]->adminLabel; |
|
91 | 91 | // Don't show as a child input |
92 | - unset( $field['parent'] ); |
|
92 | + unset( $field[ 'parent' ] ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $fields[ $key ] = $field; |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * @param \GV\Entry $entry The entry. |
39 | 39 | * @param \GV\Request $request The request context. |
40 | 40 | * |
41 | - * @return mixed $value The filtered value. |
|
41 | + * @return string $value The filtered value. |
|
42 | 42 | */ |
43 | 43 | public function get_value( $value, $field, $view, $source, $entry, $request ) { |
44 | 44 | /** Passwords should never be exposed. */ |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * Add admin script to the no-conflict scripts whitelist |
203 | 203 | * @param array $allowed Scripts allowed in no-conflict mode |
204 | - * @return array Scripts allowed in no-conflict mode, plus the search widget script |
|
204 | + * @return string[] Scripts allowed in no-conflict mode, plus the search widget script |
|
205 | 205 | */ |
206 | 206 | public function register_no_conflict( $allowed ) { |
207 | 207 | $allowed[] = 'gravityview_searchwidget_admin'; |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | /** |
890 | 890 | * Get the label for a search form field |
891 | 891 | * @param array $field Field setting as sent by the GV configuration - has `field`, `input` (input type), and `label` keys |
892 | - * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
|
892 | + * @param GF_Field|null $form_field Form field data, as fetched by `gravityview_get_field()` |
|
893 | 893 | * @return string Label for the search form |
894 | 894 | */ |
895 | 895 | private static function get_field_label( $field, $form_field = array() ) { |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | /** |
1059 | 1059 | * Require the datepicker script for the frontend GV script |
1060 | 1060 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
1061 | - * @return array Array required scripts, with `jquery-ui-datepicker` added |
|
1061 | + * @return string[] Array required scripts, with `jquery-ui-datepicker` added |
|
1062 | 1062 | */ |
1063 | 1063 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1064 | 1064 | |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | /** |
1071 | 1071 | * Modify the array passed to wp_localize_script() |
1072 | 1072 | * |
1073 | - * @param array $js_localization The data padded to the Javascript file |
|
1073 | + * @param array $localizations The data padded to the Javascript file |
|
1074 | 1074 | * @param array $view_data View data array with View settings |
1075 | 1075 | * |
1076 | 1076 | * @return array |
@@ -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, |
@@ -470,22 +470,22 @@ discard block |
||
470 | 470 | /** |
471 | 471 | * Include the sidebar Widgets. |
472 | 472 | */ |
473 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
473 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
474 | 474 | |
475 | 475 | foreach ( $widgets as $widget ) { |
476 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
477 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
476 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
477 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
478 | 478 | foreach ( $_fields as $field ) { |
479 | - $searchable_fields [] = $field['field']; |
|
479 | + $searchable_fields [ ] = $field[ 'field' ]; |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | 485 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
486 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
486 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
487 | 487 | foreach ( $_fields as $field ) { |
488 | - $searchable_fields [] = $field['field']; |
|
488 | + $searchable_fields [ ] = $field[ 'field' ]; |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | */ |
503 | 503 | public function filter_entries( $search_criteria, $form_id = null, $args = array() ) { |
504 | 504 | |
505 | - if( 'post' === $this->search_method ) { |
|
505 | + if ( 'post' === $this->search_method ) { |
|
506 | 506 | $get = $_POST; |
507 | 507 | } else { |
508 | 508 | $get = $_GET; |
@@ -521,14 +521,14 @@ discard block |
||
521 | 521 | $get = gv_map_deep( $get, 'rawurldecode' ); |
522 | 522 | |
523 | 523 | // Make sure array key is set up |
524 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
524 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
525 | 525 | |
526 | 526 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
527 | 527 | |
528 | 528 | // add free search |
529 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
529 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
530 | 530 | |
531 | - $search_all_value = trim( $get['gv_search'] ); |
|
531 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
532 | 532 | |
533 | 533 | /** |
534 | 534 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | } |
554 | 554 | |
555 | 555 | foreach ( $words as $word ) { |
556 | - $search_criteria['field_filters'][] = array( |
|
556 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
557 | 557 | 'key' => null, // The field ID to search |
558 | 558 | 'value' => $word, // The value to search |
559 | 559 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -563,19 +563,19 @@ discard block |
||
563 | 563 | |
564 | 564 | // start date & end date |
565 | 565 | if ( in_array( 'entry_date', $searchable_fields ) ) { |
566 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
567 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
566 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
567 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
568 | 568 | |
569 | 569 | if ( $view ) { |
570 | 570 | /** |
571 | 571 | * Override start and end dates if View is limited to some already. |
572 | 572 | */ |
573 | - if ( $start_date =$view->settings->get( 'start_date' ) ) { |
|
573 | + if ( $start_date = $view->settings->get( 'start_date' ) ) { |
|
574 | 574 | if ( $start_timestamp = strtotime( $curr_start ) ) { |
575 | 575 | $curr_start = $start_timestamp < strtotime( $start_date ) ? $start_date : $curr_start; |
576 | 576 | } |
577 | 577 | } |
578 | - if ( $end_date =$view->settings->get( 'end_date' ) ) { |
|
578 | + if ( $end_date = $view->settings->get( 'end_date' ) ) { |
|
579 | 579 | if ( $end_timestamp = strtotime( $curr_end ) ) { |
580 | 580 | $curr_end = $end_timestamp > strtotime( $end_date ) ? $end_date : $curr_end; |
581 | 581 | } |
@@ -596,22 +596,22 @@ discard block |
||
596 | 596 | */ |
597 | 597 | if ( ! empty( $curr_start ) ) { |
598 | 598 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
599 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
599 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | if ( ! empty( $curr_end ) ) { |
603 | 603 | // Fast-forward 24 hour on the end time |
604 | 604 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
605 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
606 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
607 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
605 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
606 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
607 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
612 | 612 | // search for a specific entry ID |
613 | 613 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
614 | - $search_criteria['field_filters'][] = array( |
|
614 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
615 | 615 | 'key' => 'id', |
616 | 616 | 'value' => absint( $get[ 'gv_id' ] ), |
617 | 617 | 'operator' => '=', |
@@ -620,42 +620,42 @@ discard block |
||
620 | 620 | |
621 | 621 | // search for a specific Created_by ID |
622 | 622 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'entry_creator', $searchable_fields ) ) { |
623 | - $search_criteria['field_filters'][] = array( |
|
623 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
624 | 624 | 'key' => 'created_by', |
625 | - 'value' => absint( $get['gv_by'] ), |
|
625 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
626 | 626 | 'operator' => '=', |
627 | 627 | ); |
628 | 628 | } |
629 | 629 | |
630 | 630 | |
631 | 631 | // Get search mode passed in URL |
632 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
632 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
633 | 633 | |
634 | 634 | // get the other search filters |
635 | 635 | foreach ( $get as $key => $value ) { |
636 | 636 | |
637 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
637 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
638 | 638 | continue; |
639 | 639 | } |
640 | 640 | |
641 | 641 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
642 | 642 | |
643 | 643 | // could return simple filter or multiple filters |
644 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
644 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
645 | 645 | continue; |
646 | 646 | } |
647 | 647 | |
648 | 648 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
649 | 649 | |
650 | - if ( isset( $filter[0]['value'] ) ) { |
|
651 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
650 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
651 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
652 | 652 | |
653 | 653 | // if date range type, set search mode to ALL |
654 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
654 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
655 | 655 | $mode = 'all'; |
656 | 656 | } |
657 | - } elseif( !empty( $filter ) ) { |
|
658 | - $search_criteria['field_filters'][] = $filter; |
|
657 | + } elseif ( ! empty( $filter ) ) { |
|
658 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | * @since 1.5.1 |
665 | 665 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
666 | 666 | */ |
667 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
667 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
668 | 668 | |
669 | 669 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
670 | 670 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | $field_id = str_replace( 'filter_', '', $key ); |
693 | 693 | |
694 | 694 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
695 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
695 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
696 | 696 | $field_id = str_replace( '_', '.', $field_id ); |
697 | 697 | } |
698 | 698 | |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | |
728 | 728 | case 'select': |
729 | 729 | case 'radio': |
730 | - $filter['operator'] = 'is'; |
|
730 | + $filter[ 'operator' ] = 'is'; |
|
731 | 731 | break; |
732 | 732 | |
733 | 733 | case 'post_category': |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | |
742 | 742 | foreach ( $value as $val ) { |
743 | 743 | $cat = get_term( $val, 'category' ); |
744 | - $filter[] = array( |
|
744 | + $filter[ ] = array( |
|
745 | 745 | 'key' => $filter_key, |
746 | 746 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
747 | 747 | 'operator' => 'is', |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | $filter = array(); |
761 | 761 | |
762 | 762 | foreach ( $value as $val ) { |
763 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
763 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | break; |
@@ -769,9 +769,9 @@ discard block |
||
769 | 769 | // convert checkbox on/off into the correct search filter |
770 | 770 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
771 | 771 | foreach ( $form_field->inputs as $k => $input ) { |
772 | - if ( $input['id'] == $filter_key ) { |
|
773 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
774 | - $filter['operator'] = 'is'; |
|
772 | + if ( $input[ 'id' ] == $filter_key ) { |
|
773 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
774 | + $filter[ 'operator' ] = 'is'; |
|
775 | 775 | break; |
776 | 776 | } |
777 | 777 | } |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | $filter = array(); |
782 | 782 | |
783 | 783 | foreach ( $value as $val ) { |
784 | - $filter[] = array( |
|
784 | + $filter[ ] = array( |
|
785 | 785 | 'key' => $filter_key, |
786 | 786 | 'value' => $val, |
787 | 787 | 'operator' => 'is', |
@@ -802,9 +802,9 @@ discard block |
||
802 | 802 | foreach ( $words as $word ) { |
803 | 803 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
804 | 804 | // Keep the same key for each filter |
805 | - $filter['value'] = $word; |
|
805 | + $filter[ 'value' ] = $word; |
|
806 | 806 | // Add a search for the value |
807 | - $filters[] = $filter; |
|
807 | + $filters[ ] = $filter; |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | |
@@ -831,19 +831,19 @@ discard block |
||
831 | 831 | * @since 1.16.3 |
832 | 832 | * Safeguard until GF implements '<=' operator |
833 | 833 | */ |
834 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
834 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
835 | 835 | $operator = '<'; |
836 | 836 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
837 | 837 | } |
838 | 838 | |
839 | - $filter[] = array( |
|
839 | + $filter[ ] = array( |
|
840 | 840 | 'key' => $filter_key, |
841 | 841 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
842 | 842 | 'operator' => $operator, |
843 | 843 | ); |
844 | 844 | } |
845 | 845 | } else { |
846 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
846 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | break; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | 'ymd_dot' => 'Y.m.d', |
875 | 875 | ); |
876 | 876 | |
877 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
877 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
878 | 878 | $format = $datepicker[ $field->dateFormat ]; |
879 | 879 | } |
880 | 880 | |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | public function add_template_path( $file_paths ) { |
906 | 906 | |
907 | 907 | // Index 100 is the default GravityView template path. |
908 | - $file_paths[102] = self::$file . 'templates/'; |
|
908 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
909 | 909 | |
910 | 910 | return $file_paths; |
911 | 911 | } |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | $has_date = false; |
925 | 925 | |
926 | 926 | foreach ( $search_fields as $k => $field ) { |
927 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
927 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
928 | 928 | $has_date = true; |
929 | 929 | break; |
930 | 930 | } |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | } |
952 | 952 | |
953 | 953 | // get configured search fields |
954 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
954 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
955 | 955 | |
956 | 956 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
957 | 957 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -966,34 +966,34 @@ discard block |
||
966 | 966 | |
967 | 967 | $updated_field = $this->get_search_filter_details( $updated_field ); |
968 | 968 | |
969 | - switch ( $field['field'] ) { |
|
969 | + switch ( $field[ 'field' ] ) { |
|
970 | 970 | |
971 | 971 | case 'search_all': |
972 | - $updated_field['key'] = 'search_all'; |
|
973 | - $updated_field['input'] = 'search_all'; |
|
974 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
972 | + $updated_field[ 'key' ] = 'search_all'; |
|
973 | + $updated_field[ 'input' ] = 'search_all'; |
|
974 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
975 | 975 | break; |
976 | 976 | |
977 | 977 | case 'entry_date': |
978 | - $updated_field['key'] = 'entry_date'; |
|
979 | - $updated_field['input'] = 'entry_date'; |
|
980 | - $updated_field['value'] = array( |
|
978 | + $updated_field[ 'key' ] = 'entry_date'; |
|
979 | + $updated_field[ 'input' ] = 'entry_date'; |
|
980 | + $updated_field[ 'value' ] = array( |
|
981 | 981 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
982 | 982 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
983 | 983 | ); |
984 | 984 | break; |
985 | 985 | |
986 | 986 | case 'entry_id': |
987 | - $updated_field['key'] = 'entry_id'; |
|
988 | - $updated_field['input'] = 'entry_id'; |
|
989 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
987 | + $updated_field[ 'key' ] = 'entry_id'; |
|
988 | + $updated_field[ 'input' ] = 'entry_id'; |
|
989 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
990 | 990 | break; |
991 | 991 | |
992 | 992 | case 'created_by': |
993 | - $updated_field['key'] = 'created_by'; |
|
994 | - $updated_field['name'] = 'gv_by'; |
|
995 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
996 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
993 | + $updated_field[ 'key' ] = 'created_by'; |
|
994 | + $updated_field[ 'name' ] = 'gv_by'; |
|
995 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
996 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
997 | 997 | break; |
998 | 998 | } |
999 | 999 | |
@@ -1012,16 +1012,16 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1014 | 1014 | |
1015 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1015 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1016 | 1016 | |
1017 | 1017 | /** @since 1.14 */ |
1018 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1018 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1019 | 1019 | |
1020 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1020 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1021 | 1021 | |
1022 | 1022 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1023 | 1023 | |
1024 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1024 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1025 | 1025 | |
1026 | 1026 | if ( $this->has_date_field( $search_fields ) ) { |
1027 | 1027 | // enqueue datepicker stuff only if needed! |
@@ -1043,10 +1043,10 @@ discard block |
||
1043 | 1043 | public static function get_search_class( $custom_class = '' ) { |
1044 | 1044 | $gravityview_view = GravityView_View::getInstance(); |
1045 | 1045 | |
1046 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1046 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1047 | 1047 | |
1048 | - if ( ! empty( $custom_class ) ) { |
|
1049 | - $search_class .= ' '.$custom_class; |
|
1048 | + if ( ! empty( $custom_class ) ) { |
|
1049 | + $search_class .= ' ' . $custom_class; |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | /** |
@@ -1090,9 +1090,9 @@ discard block |
||
1090 | 1090 | |
1091 | 1091 | if ( ! $label ) { |
1092 | 1092 | |
1093 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1093 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1094 | 1094 | |
1095 | - switch( $field['field'] ) { |
|
1095 | + switch ( $field[ 'field' ] ) { |
|
1096 | 1096 | case 'search_all': |
1097 | 1097 | $label = __( 'Search Entries:', 'gravityview' ); |
1098 | 1098 | break; |
@@ -1104,10 +1104,10 @@ discard block |
||
1104 | 1104 | break; |
1105 | 1105 | default: |
1106 | 1106 | // If this is a field input, not a field |
1107 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1107 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1108 | 1108 | |
1109 | 1109 | // Get the label for the field in question, which returns an array |
1110 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1110 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1111 | 1111 | |
1112 | 1112 | // Get the item with the `label` key |
1113 | 1113 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1146,32 +1146,32 @@ discard block |
||
1146 | 1146 | $form = $gravityview_view->getForm(); |
1147 | 1147 | |
1148 | 1148 | // for advanced field ids (eg, first name / last name ) |
1149 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1149 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1150 | 1150 | |
1151 | 1151 | // get searched value from $_GET/$_POST (string or array) |
1152 | 1152 | $value = $this->rgget_or_rgpost( $name ); |
1153 | 1153 | |
1154 | 1154 | // get form field details |
1155 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1155 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1156 | 1156 | |
1157 | 1157 | $filter = array( |
1158 | - 'key' => $field['field'], |
|
1158 | + 'key' => $field[ 'field' ], |
|
1159 | 1159 | 'name' => $name, |
1160 | 1160 | 'label' => self::get_field_label( $field, $form_field ), |
1161 | - 'input' => $field['input'], |
|
1161 | + 'input' => $field[ 'input' ], |
|
1162 | 1162 | 'value' => $value, |
1163 | - 'type' => $form_field['type'], |
|
1163 | + 'type' => $form_field[ 'type' ], |
|
1164 | 1164 | ); |
1165 | 1165 | |
1166 | 1166 | // collect choices |
1167 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1168 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1169 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1170 | - $filter['choices'] = $form_field['choices']; |
|
1167 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1168 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1169 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1170 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1174 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1173 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1174 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | return $filter; |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | |
1196 | 1196 | $choices = array(); |
1197 | 1197 | foreach ( $users as $user ) { |
1198 | - $choices[] = array( |
|
1198 | + $choices[ ] = array( |
|
1199 | 1199 | 'value' => $user->ID, |
1200 | 1200 | 'text' => $user->display_name, |
1201 | 1201 | ); |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | */ |
1251 | 1251 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1252 | 1252 | |
1253 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1253 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1254 | 1254 | |
1255 | 1255 | return $js_dependencies; |
1256 | 1256 | } |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | 'isRTL' => is_rtl(), |
1295 | 1295 | ), $view_data ); |
1296 | 1296 | |
1297 | - $localizations['datepicker'] = $datepicker_settings; |
|
1297 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1298 | 1298 | |
1299 | 1299 | return $localizations; |
1300 | 1300 | |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | * @return void |
1322 | 1322 | */ |
1323 | 1323 | private function maybe_enqueue_flexibility() { |
1324 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1324 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1325 | 1325 | wp_enqueue_script( 'gv-flexibility' ); |
1326 | 1326 | } |
1327 | 1327 | } |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1344 | 1344 | |
1345 | 1345 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1346 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1346 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1347 | 1347 | |
1348 | 1348 | /** |
1349 | 1349 | * @filter `gravityview_search_datepicker_class` |
@@ -603,7 +603,8 @@ discard block |
||
603 | 603 | // Fast-forward 24 hour on the end time |
604 | 604 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
605 | 605 | $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
606 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
606 | + if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { |
|
607 | +// See https://github.com/gravityview/GravityView/issues/1056 |
|
607 | 608 | $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
608 | 609 | } |
609 | 610 | } |
@@ -874,7 +875,7 @@ discard block |
||
874 | 875 | 'ymd_dot' => 'Y.m.d', |
875 | 876 | ); |
876 | 877 | |
877 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
878 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
878 | 879 | $format = $datepicker[ $field->dateFormat ]; |
879 | 880 | } |
880 | 881 |