@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | public function dismiss_notice() { |
61 | 61 | |
62 | 62 | // No dismiss sent |
63 | - if( empty( $_GET['gv-dismiss'] ) ) { |
|
63 | + if ( empty( $_GET[ 'gv-dismiss' ] ) ) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | 67 | // Invalid nonce |
68 | - if( !wp_verify_nonce( $_GET['gv-dismiss'], 'dismiss' ) ) { |
|
68 | + if ( ! wp_verify_nonce( $_GET[ 'gv-dismiss' ], 'dismiss' ) ) { |
|
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
72 | - $notice_id = esc_attr( $_GET['notice'] ); |
|
72 | + $notice_id = esc_attr( $_GET[ 'notice' ] ); |
|
73 | 73 | |
74 | 74 | //don't display a message if use has dismissed the message for this version |
75 | 75 | $dismissed_notices = (array)get_transient( 'gravityview_dismissed_notices' ); |
76 | 76 | |
77 | - $dismissed_notices[] = $notice_id; |
|
77 | + $dismissed_notices[ ] = $notice_id; |
|
78 | 78 | |
79 | 79 | $dismissed_notices = array_unique( $dismissed_notices ); |
80 | 80 | |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | private function is_notice_dismissed( $notice ) { |
98 | 98 | |
99 | 99 | // There are no dismissed notices. |
100 | - if( empty( self::$dismissed_notices ) ) { |
|
100 | + if ( empty( self::$dismissed_notices ) ) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Has the |
105 | - $is_dismissed = !empty( $notice['dismiss'] ) && in_array( $notice['dismiss'], self::$dismissed_notices ); |
|
105 | + $is_dismissed = ! empty( $notice[ 'dismiss' ] ) && in_array( $notice[ 'dismiss' ], self::$dismissed_notices ); |
|
106 | 106 | |
107 | 107 | return $is_dismissed ? true : false; |
108 | 108 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | private function check_show_multisite_notices() { |
129 | 129 | |
130 | - if( ! is_multisite() ) { |
|
130 | + if ( ! is_multisite() ) { |
|
131 | 131 | return true; |
132 | 132 | } |
133 | 133 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | // or they don't have admin capabilities |
140 | - if( ! is_super_admin() ) { |
|
140 | + if ( ! is_super_admin() ) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
@@ -160,48 +160,48 @@ discard block |
||
160 | 160 | */ |
161 | 161 | $notices = apply_filters( 'gravityview/admin/notices', self::$admin_notices ); |
162 | 162 | |
163 | - if( empty( $notices ) || ! $this->check_show_multisite_notices() ) { |
|
163 | + if ( empty( $notices ) || ! $this->check_show_multisite_notices() ) { |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | |
167 | 167 | //don't display a message if use has dismissed the message for this version |
168 | 168 | // TODO: Use get_user_meta instead of get_transient |
169 | - self::$dismissed_notices = isset( $_GET['show-dismissed-notices'] ) ? array() : (array)get_transient( 'gravityview_dismissed_notices' ); |
|
169 | + self::$dismissed_notices = isset( $_GET[ 'show-dismissed-notices' ] ) ? array() : (array)get_transient( 'gravityview_dismissed_notices' ); |
|
170 | 170 | |
171 | 171 | $output = ''; |
172 | 172 | |
173 | - foreach( $notices as $notice ) { |
|
173 | + foreach ( $notices as $notice ) { |
|
174 | 174 | |
175 | 175 | // If the user doesn't have the capability to see the warning |
176 | - if( isset( $notice['cap'] ) && false === GVCommon::has_cap( $notice['cap'] ) ) { |
|
176 | + if ( isset( $notice[ 'cap' ] ) && false === GVCommon::has_cap( $notice[ 'cap' ] ) ) { |
|
177 | 177 | gravityview()->log->debug( 'Notice not shown because user does not have the capability to view it.', array( 'data' => $notice ) ); |
178 | 178 | continue; |
179 | 179 | } |
180 | 180 | |
181 | - if( true === $this->is_notice_dismissed( $notice ) ) { |
|
181 | + if ( true === $this->is_notice_dismissed( $notice ) ) { |
|
182 | 182 | gravityview()->log->debug( 'Notice not shown because the notice has already been dismissed.', array( 'data' => $notice ) ); |
183 | 183 | continue; |
184 | 184 | } |
185 | 185 | |
186 | - $output .= '<div id="message" style="position:relative" class="notice '. gravityview_sanitize_html_class( $notice['class'] ).'">'; |
|
186 | + $output .= '<div id="message" style="position:relative" class="notice ' . gravityview_sanitize_html_class( $notice[ 'class' ] ) . '">'; |
|
187 | 187 | |
188 | 188 | // Too cute to leave out. |
189 | 189 | $output .= gravityview_get_floaty(); |
190 | 190 | |
191 | - if( !empty( $notice['title'] ) ) { |
|
192 | - $output .= '<h3>'.esc_html( $notice['title'] ) .'</h3>'; |
|
191 | + if ( ! empty( $notice[ 'title' ] ) ) { |
|
192 | + $output .= '<h3>' . esc_html( $notice[ 'title' ] ) . '</h3>'; |
|
193 | 193 | } |
194 | 194 | |
195 | - $message = isset( $notice['message'] ) ? $notice['message'] : ''; |
|
195 | + $message = isset( $notice[ 'message' ] ) ? $notice[ 'message' ] : ''; |
|
196 | 196 | |
197 | - if( !empty( $notice['dismiss'] ) ) { |
|
197 | + if ( ! empty( $notice[ 'dismiss' ] ) ) { |
|
198 | 198 | |
199 | - $dismiss = esc_attr($notice['dismiss']); |
|
199 | + $dismiss = esc_attr( $notice[ 'dismiss' ] ); |
|
200 | 200 | |
201 | 201 | $url = esc_url( add_query_arg( array( 'gv-dismiss' => wp_create_nonce( 'dismiss' ), 'notice' => $dismiss ) ) ); |
202 | 202 | |
203 | 203 | $align = is_rtl() ? 'alignleft' : 'alignright'; |
204 | - $message .= '<a href="'.$url.'" data-notice="'.$dismiss.'" class="' . $align . ' button button-link">'.esc_html__('Dismiss', 'gravityview' ).'</a></p>'; |
|
204 | + $message .= '<a href="' . $url . '" data-notice="' . $dismiss . '" class="' . $align . ' button button-link">' . esc_html__( 'Dismiss', 'gravityview' ) . '</a></p>'; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | $output .= wpautop( $message ); |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public static function add_notice( $notice = array() ) { |
235 | 235 | |
236 | - if( !isset( $notice['message'] ) ) { |
|
236 | + if ( ! isset( $notice[ 'message' ] ) ) { |
|
237 | 237 | gravityview()->log->error( 'Notice not set', array( 'data' => $notice ) ); |
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
241 | + $notice[ 'class' ] = empty( $notice[ 'class' ] ) ? 'error' : $notice[ 'class' ]; |
|
242 | 242 | |
243 | - self::$admin_notices[] = $notice; |
|
243 | + self::$admin_notices[ ] = $notice; |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | $new_value = $old_value; |
114 | 114 | |
115 | 115 | // Meta value does not exist yet |
116 | - if( false === $old_value ) { |
|
116 | + if ( false === $old_value ) { |
|
117 | 117 | return self::UNAPPROVED; |
118 | 118 | } |
119 | 119 | |
120 | 120 | // Meta value does not exist yet |
121 | - if( true === $old_value ) { |
|
121 | + if ( true === $old_value ) { |
|
122 | 122 | return self::APPROVED; |
123 | 123 | } |
124 | 124 | |
125 | - switch ( (string) $old_value ) { |
|
125 | + switch ( (string)$old_value ) { |
|
126 | 126 | |
127 | 127 | // Approved values |
128 | 128 | case 'Approved': |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | foreach ( $choices as $key => $choice ) { |
249 | 249 | |
250 | 250 | // Is the passed status value the same as the choice value or key? |
251 | - if ( $status === $choice['value'] || $status === $key ) { |
|
251 | + if ( $status === $choice[ 'value' ] || $status === $key ) { |
|
252 | 252 | |
253 | - if( 'key' === $attr_key ) { |
|
253 | + if ( 'key' === $attr_key ) { |
|
254 | 254 | return $key; |
255 | 255 | } else { |
256 | 256 | return \GV\Utils::get( $choice, $attr_key, false ); |
@@ -11,35 +11,35 @@ discard block |
||
11 | 11 | |
12 | 12 | function __construct() { |
13 | 13 | |
14 | - $this->widget_description = __('Links to multiple pages of results.', 'gravityview' ); |
|
14 | + $this->widget_description = __( 'Links to multiple pages of results.', 'gravityview' ); |
|
15 | 15 | |
16 | 16 | $default_values = array( 'header' => 1, 'footer' => 1 ); |
17 | 17 | $settings = array( 'show_all' => array( |
18 | 18 | 'type' => 'checkbox', |
19 | 19 | 'label' => __( 'Show each page number', 'gravityview' ), |
20 | - 'desc' => __('Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview'), |
|
20 | + 'desc' => __( 'Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview' ), |
|
21 | 21 | 'value' => false |
22 | - )); |
|
23 | - parent::__construct( __( 'Page Links', 'gravityview' ) , 'page_links', $default_values, $settings ); |
|
22 | + ) ); |
|
23 | + parent::__construct( __( 'Page Links', 'gravityview' ), 'page_links', $default_values, $settings ); |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | |
27 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
27 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
28 | 28 | $gravityview_view = GravityView_View::getInstance(); |
29 | 29 | |
30 | - if( !$this->pre_render_frontend() ) { |
|
30 | + if ( ! $this->pre_render_frontend() ) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | 34 | $atts = shortcode_atts( array( |
35 | 35 | 'page_size' => \GV\Utils::get( $gravityview_view->paging, 'page_size' ), |
36 | 36 | 'total' => $gravityview_view->total_entries, |
37 | - 'show_all' => !empty( $this->settings['show_all']['default'] ), |
|
38 | - 'current' => (int) \GV\Utils::_GET( 'pagenum', 1 ), |
|
37 | + 'show_all' => ! empty( $this->settings[ 'show_all' ][ 'default' ] ), |
|
38 | + 'current' => (int)\GV\Utils::_GET( 'pagenum', 1 ), |
|
39 | 39 | ), $widget_args, 'gravityview_widget_page_links' ); |
40 | 40 | |
41 | 41 | $page_link_args = array( |
42 | - 'base' => add_query_arg('pagenum','%#%', gv_directory_link() ), |
|
42 | + 'base' => add_query_arg( 'pagenum', '%#%', gv_directory_link() ), |
|
43 | 43 | 'format' => '&pagenum=%#%', |
44 | 44 | 'add_args' => array(), // |
45 | 45 | 'prev_text' => '«', |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | 'type' => 'list', |
48 | 48 | 'end_size' => 1, |
49 | 49 | 'mid_size' => 2, |
50 | - 'total' => empty( $atts['page_size'] ) ? 0 : ceil( $atts['total'] / $atts['page_size'] ), |
|
51 | - 'current' => $atts['current'], |
|
52 | - 'show_all' => !empty( $atts['show_all'] ), // to be available at backoffice |
|
50 | + 'total' => empty( $atts[ 'page_size' ] ) ? 0 : ceil( $atts[ 'total' ] / $atts[ 'page_size' ] ), |
|
51 | + 'current' => $atts[ 'current' ], |
|
52 | + 'show_all' => ! empty( $atts[ 'show_all' ] ), // to be available at backoffice |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | /** |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | * @since 1.1.4 |
58 | 58 | * @param array $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/) |
59 | 59 | */ |
60 | - $page_link_args = apply_filters('gravityview_page_links_args', $page_link_args ); |
|
60 | + $page_link_args = apply_filters( 'gravityview_page_links_args', $page_link_args ); |
|
61 | 61 | |
62 | 62 | $page_links = paginate_links( $page_link_args ); |
63 | 63 | |
64 | - if( !empty( $page_links )) { |
|
65 | - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
64 | + if ( ! empty( $page_links ) ) { |
|
65 | + $class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
66 | 66 | $class = gravityview_sanitize_html_class( 'gv-widget-page-links ' . $class ); |
67 | - echo '<div class="'.$class.'">'. $page_links .'</div>'; |
|
67 | + echo '<div class="' . $class . '">' . $page_links . '</div>'; |
|
68 | 68 | } else { |
69 | 69 | gravityview()->log->debug( 'No page links; paginate_links() returned empty response.' ); |
70 | 70 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | function __construct() { |
19 | 19 | |
20 | - $this->widget_description = __('Insert custom text or HTML as a widget', 'gravityview' ); |
|
20 | + $this->widget_description = __( 'Insert custom text or HTML as a widget', 'gravityview' ); |
|
21 | 21 | |
22 | 22 | $default_values = array( |
23 | 23 | 'header' => 1, |
@@ -42,39 +42,39 @@ discard block |
||
42 | 42 | ), |
43 | 43 | ); |
44 | 44 | |
45 | - parent::__construct( __( 'Custom Content', 'gravityview' ) , 'custom_content', $default_values, $settings ); |
|
45 | + parent::__construct( __( 'Custom Content', 'gravityview' ), 'custom_content', $default_values, $settings ); |
|
46 | 46 | } |
47 | 47 | |
48 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
48 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
49 | 49 | |
50 | - if( !$this->pre_render_frontend() ) { |
|
50 | + if ( ! $this->pre_render_frontend() ) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | - if( !empty( $widget_args['title'] ) ) { |
|
55 | - echo $widget_args['title']; |
|
54 | + if ( ! empty( $widget_args[ 'title' ] ) ) { |
|
55 | + echo $widget_args[ 'title' ]; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
59 | 59 | // Make sure the class is loaded in DataTables |
60 | - if( !class_exists( 'GFFormDisplay' ) ) { |
|
60 | + if ( ! class_exists( 'GFFormDisplay' ) ) { |
|
61 | 61 | include_once( GFCommon::get_base_path() . '/form_display.php' ); |
62 | 62 | } |
63 | 63 | |
64 | - $widget_args['content'] = trim( rtrim( $widget_args['content'] ) ); |
|
64 | + $widget_args[ 'content' ] = trim( rtrim( $widget_args[ 'content' ] ) ); |
|
65 | 65 | |
66 | 66 | // No custom content |
67 | - if( empty( $widget_args['content'] ) ) { |
|
67 | + if ( empty( $widget_args[ 'content' ] ) ) { |
|
68 | 68 | gravityview()->log->debug( 'No content.' ); |
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Add paragraphs? |
73 | - if( !empty( $widget_args['wpautop'] ) ) { |
|
74 | - $widget_args['content'] = wpautop( $widget_args['content'] ); |
|
73 | + if ( ! empty( $widget_args[ 'wpautop' ] ) ) { |
|
74 | + $widget_args[ 'content' ] = wpautop( $widget_args[ 'content' ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | - $content = $widget_args['content']; |
|
77 | + $content = $widget_args[ 'content' ]; |
|
78 | 78 | |
79 | 79 | $content = GravityView_Merge_Tags::replace_variables( $content, array(), array(), false, true, false ); |
80 | 80 | |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | |
85 | 85 | |
86 | 86 | // Add custom class |
87 | - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
87 | + $class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
88 | 88 | $class = gravityview_sanitize_html_class( $class ); |
89 | 89 | |
90 | - echo '<div class="gv-widget-custom-content '.$class.'">'. $content .'</div>'; |
|
90 | + echo '<div class="gv-widget-custom-content ' . $class . '">' . $content . '</div>'; |
|
91 | 91 | |
92 | 92 | } |
93 | 93 |
@@ -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,19 +596,19 @@ 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; |
|
605 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
609 | 609 | // search for a specific entry ID |
610 | 610 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
611 | - $search_criteria['field_filters'][] = array( |
|
611 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
612 | 612 | 'key' => 'id', |
613 | 613 | 'value' => absint( $get[ 'gv_id' ] ), |
614 | 614 | 'operator' => '=', |
@@ -617,42 +617,42 @@ discard block |
||
617 | 617 | |
618 | 618 | // search for a specific Created_by ID |
619 | 619 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'entry_creator', $searchable_fields ) ) { |
620 | - $search_criteria['field_filters'][] = array( |
|
620 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
621 | 621 | 'key' => 'created_by', |
622 | - 'value' => absint( $get['gv_by'] ), |
|
622 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
623 | 623 | 'operator' => '=', |
624 | 624 | ); |
625 | 625 | } |
626 | 626 | |
627 | 627 | |
628 | 628 | // Get search mode passed in URL |
629 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
629 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
630 | 630 | |
631 | 631 | // get the other search filters |
632 | 632 | foreach ( $get as $key => $value ) { |
633 | 633 | |
634 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
634 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
635 | 635 | continue; |
636 | 636 | } |
637 | 637 | |
638 | 638 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
639 | 639 | |
640 | 640 | // could return simple filter or multiple filters |
641 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
641 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
642 | 642 | continue; |
643 | 643 | } |
644 | 644 | |
645 | 645 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
646 | 646 | |
647 | - if ( isset( $filter[0]['value'] ) ) { |
|
648 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
647 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
648 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
649 | 649 | |
650 | 650 | // if date range type, set search mode to ALL |
651 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
651 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
652 | 652 | $mode = 'all'; |
653 | 653 | } |
654 | - } elseif( !empty( $filter ) ) { |
|
655 | - $search_criteria['field_filters'][] = $filter; |
|
654 | + } elseif ( ! empty( $filter ) ) { |
|
655 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | * @since 1.5.1 |
662 | 662 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
663 | 663 | */ |
664 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
664 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
665 | 665 | |
666 | 666 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
667 | 667 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | $field_id = str_replace( 'filter_', '', $key ); |
690 | 690 | |
691 | 691 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
692 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
692 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
693 | 693 | $field_id = str_replace( '_', '.', $field_id ); |
694 | 694 | } |
695 | 695 | |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | case 'select': |
726 | 726 | case 'radio': |
727 | - $filter['operator'] = 'is'; |
|
727 | + $filter[ 'operator' ] = 'is'; |
|
728 | 728 | break; |
729 | 729 | |
730 | 730 | case 'post_category': |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | foreach ( $value as $val ) { |
740 | 740 | $cat = get_term( $val, 'category' ); |
741 | - $filter[] = array( |
|
741 | + $filter[ ] = array( |
|
742 | 742 | 'key' => $filter_key, |
743 | 743 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
744 | 744 | 'operator' => 'is', |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | $filter = array(); |
758 | 758 | |
759 | 759 | foreach ( $value as $val ) { |
760 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
760 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | break; |
@@ -766,9 +766,9 @@ discard block |
||
766 | 766 | // convert checkbox on/off into the correct search filter |
767 | 767 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
768 | 768 | foreach ( $form_field->inputs as $k => $input ) { |
769 | - if ( $input['id'] == $filter_key ) { |
|
770 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
771 | - $filter['operator'] = 'is'; |
|
769 | + if ( $input[ 'id' ] == $filter_key ) { |
|
770 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
771 | + $filter[ 'operator' ] = 'is'; |
|
772 | 772 | break; |
773 | 773 | } |
774 | 774 | } |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | $filter = array(); |
779 | 779 | |
780 | 780 | foreach ( $value as $val ) { |
781 | - $filter[] = array( |
|
781 | + $filter[ ] = array( |
|
782 | 782 | 'key' => $filter_key, |
783 | 783 | 'value' => $val, |
784 | 784 | 'operator' => 'is', |
@@ -799,9 +799,9 @@ discard block |
||
799 | 799 | foreach ( $words as $word ) { |
800 | 800 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
801 | 801 | // Keep the same key for each filter |
802 | - $filter['value'] = $word; |
|
802 | + $filter[ 'value' ] = $word; |
|
803 | 803 | // Add a search for the value |
804 | - $filters[] = $filter; |
|
804 | + $filters[ ] = $filter; |
|
805 | 805 | } |
806 | 806 | } |
807 | 807 | |
@@ -828,19 +828,19 @@ discard block |
||
828 | 828 | * @since 1.16.3 |
829 | 829 | * Safeguard until GF implements '<=' operator |
830 | 830 | */ |
831 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
831 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
832 | 832 | $operator = '<'; |
833 | 833 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
834 | 834 | } |
835 | 835 | |
836 | - $filter[] = array( |
|
836 | + $filter[ ] = array( |
|
837 | 837 | 'key' => $filter_key, |
838 | 838 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
839 | 839 | 'operator' => $operator, |
840 | 840 | ); |
841 | 841 | } |
842 | 842 | } else { |
843 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
843 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | break; |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | 'ymd_dot' => 'Y.m.d', |
872 | 872 | ); |
873 | 873 | |
874 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
874 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
875 | 875 | $format = $datepicker[ $field->dateFormat ]; |
876 | 876 | } |
877 | 877 | |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | public function add_template_path( $file_paths ) { |
903 | 903 | |
904 | 904 | // Index 100 is the default GravityView template path. |
905 | - $file_paths[102] = self::$file . 'templates/'; |
|
905 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
906 | 906 | |
907 | 907 | return $file_paths; |
908 | 908 | } |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | $has_date = false; |
922 | 922 | |
923 | 923 | foreach ( $search_fields as $k => $field ) { |
924 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
924 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
925 | 925 | $has_date = true; |
926 | 926 | break; |
927 | 927 | } |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | } |
949 | 949 | |
950 | 950 | // get configured search fields |
951 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
951 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
952 | 952 | |
953 | 953 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
954 | 954 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -963,34 +963,34 @@ discard block |
||
963 | 963 | |
964 | 964 | $updated_field = $this->get_search_filter_details( $updated_field ); |
965 | 965 | |
966 | - switch ( $field['field'] ) { |
|
966 | + switch ( $field[ 'field' ] ) { |
|
967 | 967 | |
968 | 968 | case 'search_all': |
969 | - $updated_field['key'] = 'search_all'; |
|
970 | - $updated_field['input'] = 'search_all'; |
|
971 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
969 | + $updated_field[ 'key' ] = 'search_all'; |
|
970 | + $updated_field[ 'input' ] = 'search_all'; |
|
971 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
972 | 972 | break; |
973 | 973 | |
974 | 974 | case 'entry_date': |
975 | - $updated_field['key'] = 'entry_date'; |
|
976 | - $updated_field['input'] = 'entry_date'; |
|
977 | - $updated_field['value'] = array( |
|
975 | + $updated_field[ 'key' ] = 'entry_date'; |
|
976 | + $updated_field[ 'input' ] = 'entry_date'; |
|
977 | + $updated_field[ 'value' ] = array( |
|
978 | 978 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
979 | 979 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
980 | 980 | ); |
981 | 981 | break; |
982 | 982 | |
983 | 983 | case 'entry_id': |
984 | - $updated_field['key'] = 'entry_id'; |
|
985 | - $updated_field['input'] = 'entry_id'; |
|
986 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
984 | + $updated_field[ 'key' ] = 'entry_id'; |
|
985 | + $updated_field[ 'input' ] = 'entry_id'; |
|
986 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
987 | 987 | break; |
988 | 988 | |
989 | 989 | case 'created_by': |
990 | - $updated_field['key'] = 'created_by'; |
|
991 | - $updated_field['name'] = 'gv_by'; |
|
992 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
993 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
990 | + $updated_field[ 'key' ] = 'created_by'; |
|
991 | + $updated_field[ 'name' ] = 'gv_by'; |
|
992 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
993 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
994 | 994 | break; |
995 | 995 | } |
996 | 996 | |
@@ -1009,16 +1009,16 @@ discard block |
||
1009 | 1009 | */ |
1010 | 1010 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1011 | 1011 | |
1012 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1012 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1013 | 1013 | |
1014 | 1014 | /** @since 1.14 */ |
1015 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1015 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1016 | 1016 | |
1017 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1017 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1018 | 1018 | |
1019 | 1019 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1020 | 1020 | |
1021 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1021 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1022 | 1022 | |
1023 | 1023 | if ( $this->has_date_field( $search_fields ) ) { |
1024 | 1024 | // enqueue datepicker stuff only if needed! |
@@ -1040,10 +1040,10 @@ discard block |
||
1040 | 1040 | public static function get_search_class( $custom_class = '' ) { |
1041 | 1041 | $gravityview_view = GravityView_View::getInstance(); |
1042 | 1042 | |
1043 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1043 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1044 | 1044 | |
1045 | - if ( ! empty( $custom_class ) ) { |
|
1046 | - $search_class .= ' '.$custom_class; |
|
1045 | + if ( ! empty( $custom_class ) ) { |
|
1046 | + $search_class .= ' ' . $custom_class; |
|
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | /** |
@@ -1087,9 +1087,9 @@ discard block |
||
1087 | 1087 | |
1088 | 1088 | if ( ! $label ) { |
1089 | 1089 | |
1090 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1090 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1091 | 1091 | |
1092 | - switch( $field['field'] ) { |
|
1092 | + switch ( $field[ 'field' ] ) { |
|
1093 | 1093 | case 'search_all': |
1094 | 1094 | $label = __( 'Search Entries:', 'gravityview' ); |
1095 | 1095 | break; |
@@ -1101,10 +1101,10 @@ discard block |
||
1101 | 1101 | break; |
1102 | 1102 | default: |
1103 | 1103 | // If this is a field input, not a field |
1104 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1104 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1105 | 1105 | |
1106 | 1106 | // Get the label for the field in question, which returns an array |
1107 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1107 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1108 | 1108 | |
1109 | 1109 | // Get the item with the `label` key |
1110 | 1110 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1143,32 +1143,32 @@ discard block |
||
1143 | 1143 | $form = $gravityview_view->getForm(); |
1144 | 1144 | |
1145 | 1145 | // for advanced field ids (eg, first name / last name ) |
1146 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1146 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1147 | 1147 | |
1148 | 1148 | // get searched value from $_GET/$_POST (string or array) |
1149 | 1149 | $value = $this->rgget_or_rgpost( $name ); |
1150 | 1150 | |
1151 | 1151 | // get form field details |
1152 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1152 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1153 | 1153 | |
1154 | 1154 | $filter = array( |
1155 | - 'key' => $field['field'], |
|
1155 | + 'key' => $field[ 'field' ], |
|
1156 | 1156 | 'name' => $name, |
1157 | 1157 | 'label' => self::get_field_label( $field, $form_field ), |
1158 | - 'input' => $field['input'], |
|
1158 | + 'input' => $field[ 'input' ], |
|
1159 | 1159 | 'value' => $value, |
1160 | - 'type' => $form_field['type'], |
|
1160 | + 'type' => $form_field[ 'type' ], |
|
1161 | 1161 | ); |
1162 | 1162 | |
1163 | 1163 | // collect choices |
1164 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1165 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1166 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1167 | - $filter['choices'] = $form_field['choices']; |
|
1164 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1165 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1166 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1167 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1171 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1170 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1171 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | return $filter; |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | $choices = array(); |
1194 | 1194 | foreach ( $users as $user ) { |
1195 | - $choices[] = array( |
|
1195 | + $choices[ ] = array( |
|
1196 | 1196 | 'value' => $user->ID, |
1197 | 1197 | 'text' => $user->display_name, |
1198 | 1198 | ); |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | */ |
1248 | 1248 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1249 | 1249 | |
1250 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1250 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1251 | 1251 | |
1252 | 1252 | return $js_dependencies; |
1253 | 1253 | } |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | 'isRTL' => is_rtl(), |
1292 | 1292 | ), $view_data ); |
1293 | 1293 | |
1294 | - $localizations['datepicker'] = $datepicker_settings; |
|
1294 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1295 | 1295 | |
1296 | 1296 | return $localizations; |
1297 | 1297 | |
@@ -1318,7 +1318,7 @@ discard block |
||
1318 | 1318 | * @return void |
1319 | 1319 | */ |
1320 | 1320 | private function maybe_enqueue_flexibility() { |
1321 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1321 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1322 | 1322 | wp_enqueue_script( 'gv-flexibility' ); |
1323 | 1323 | } |
1324 | 1324 | } |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1341 | 1341 | |
1342 | 1342 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1343 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1343 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1344 | 1344 | |
1345 | 1345 | /** |
1346 | 1346 | * @filter `gravityview_search_datepicker_class` |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | $base_url = GravityView_Widget_Search::get_search_form_action(); |
14 | 14 | |
15 | 15 | // Make sure that there are choices to display |
16 | -if ( empty( $search_field['choices'] ) ) { |
|
16 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
17 | 17 | gravityview()->log->debug( 'search-field-link.php - No choices for field' ); |
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | -$links_label = empty( $search_field['label'] ) ? __( 'Show only:', 'gravityview' ) : $search_field['label']; |
|
21 | +$links_label = empty( $search_field[ 'label' ] ) ? __( 'Show only:', 'gravityview' ) : $search_field[ 'label' ]; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @filter `gravityview/extension/search/links_label` Change the label for the "Link" search bar input type |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | |
42 | 42 | <?php |
43 | 43 | |
44 | - $search_value = \GV\Utils::_GET( $search_field['name'] ); |
|
44 | + $search_value = \GV\Utils::_GET( $search_field[ 'name' ] ); |
|
45 | 45 | |
46 | - foreach ( $search_field['choices'] as $k => $choice ) { |
|
46 | + foreach ( $search_field[ 'choices' ] as $k => $choice ) { |
|
47 | 47 | |
48 | 48 | if ( 0 != $k ) { |
49 | 49 | echo esc_html( $links_sep ); |
50 | 50 | } |
51 | 51 | |
52 | - $active = ( '' !== $search_value && in_array( $search_value, array( $choice['text'], $choice['value'] ) ) ) ? ' class="active"' : false; |
|
52 | + $active = ( '' !== $search_value && in_array( $search_value, array( $choice[ 'text' ], $choice[ 'value' ] ) ) ) ? ' class="active"' : false; |
|
53 | 53 | |
54 | 54 | if ( $active ) { |
55 | - $link = remove_query_arg( array( 'pagenum', $search_field['name'] ), $base_url ); |
|
55 | + $link = remove_query_arg( array( 'pagenum', $search_field[ 'name' ] ), $base_url ); |
|
56 | 56 | } else { |
57 | - $link = add_query_arg( array( $search_field['name'] => urlencode( $choice['value'] ) ), remove_query_arg( array('pagenum'), $base_url ) ); |
|
57 | + $link = add_query_arg( array( $search_field[ 'name' ] => urlencode( $choice[ 'value' ] ) ), remove_query_arg( array( 'pagenum' ), $base_url ) ); |
|
58 | 58 | } |
59 | 59 | ?> |
60 | 60 | |
61 | - <a href="<?php echo esc_url_raw( $link ); ?>" <?php echo $active; ?>><?php echo esc_html( $choice['text'] ); ?></a> |
|
61 | + <a href="<?php echo esc_url_raw( $link ); ?>" <?php echo $active; ?>><?php echo esc_html( $choice[ 'text' ] ); ?></a> |
|
62 | 62 | |
63 | 63 | <?php } ?> |
64 | 64 | </p> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | $search_field = $gravityview_view->search_field; |
11 | 11 | |
12 | 12 | // Make sure that there are choices to display |
13 | -if( empty( $search_field['choices'] ) ) { |
|
13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
14 | 14 | gravityview()->log->debug( 'search-field-select.php - No choices for field' ); |
15 | 15 | return; |
16 | 16 | } |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | * @param string $default_option Default: `—` (—) |
22 | 22 | * @param string $field_type Field type: "select" or "multiselect" |
23 | 23 | */ |
24 | -$default_option = apply_filters('gravityview/extension/search/select_default', '—', 'select' ); |
|
24 | +$default_option = apply_filters( 'gravityview/extension/search/select_default', '—', 'select' ); |
|
25 | 25 | |
26 | 26 | ?> |
27 | 27 | <div class="gv-search-box gv-search-field-select"> |
28 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> |
|
29 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
28 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> |
|
29 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
30 | 30 | <?php } ?> |
31 | 31 | <p> |
32 | - <select name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"> |
|
33 | - <option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option> |
|
32 | + <select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"> |
|
33 | + <option value="" <?php gv_selected( '', $search_field[ 'value' ], true ); ?>><?php echo esc_html( $default_option ); ?></option> |
|
34 | 34 | <?php |
35 | - foreach( $search_field['choices'] as $choice ) : ?> |
|
36 | - <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option> |
|
35 | + foreach ( $search_field[ 'choices' ] as $choice ) : ?> |
|
36 | + <option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( esc_attr( $choice[ 'value' ] ), esc_attr( $search_field[ 'value' ] ), true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option> |
|
37 | 37 | <?php endforeach; ?> |
38 | 38 | </select> |
39 | 39 | </p> |
@@ -10,22 +10,22 @@ |
||
10 | 10 | $search_field = $gravityview_view->search_field; |
11 | 11 | |
12 | 12 | // Make sure that there are choices to display |
13 | -if( empty( $search_field['choices'] ) ) { |
|
13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
14 | 14 | gravityview()->log->debug( 'search-field-checkbox.php - No choices for field' ); |
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="gv-search-box gv-search-field-checkbox"> |
20 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> |
|
21 | - <label for=search-box-<?php echo esc_attr( $search_field['name'] ); ?>><?php echo esc_html( $search_field['label'] ); ?></label> |
|
20 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> |
|
21 | + <label for=search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
22 | 22 | <?php } ?> |
23 | 23 | <p> |
24 | - <?php foreach( $search_field['choices'] as $choice ) { ?> |
|
24 | + <?php foreach ( $search_field[ 'choices' ] as $choice ) { ?> |
|
25 | 25 | |
26 | - <label for="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" class="gv-check-radio"> |
|
27 | - <input type="checkbox" name="<?php echo esc_attr( $search_field['name'] ); ?>[]" value="<?php echo esc_attr( $choice['value'] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" <?php gv_selected( $choice['value'], $search_field['value'], true, 'checked' ); ?>> |
|
28 | - <?php echo esc_html( $choice['text'] ); ?> |
|
26 | + <label for="search-box-<?php echo sanitize_html_class( $search_field[ 'name' ] . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" class="gv-check-radio"> |
|
27 | + <input type="checkbox" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>[]" value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field[ 'name' ] . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" <?php gv_selected( $choice[ 'value' ], $search_field[ 'value' ], true, 'checked' ); ?>> |
|
28 | + <?php echo esc_html( $choice[ 'text' ] ); ?> |
|
29 | 29 | </label> |
30 | 30 | |
31 | 31 | <?php } ?> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | do_action( 'gravityview_search_widget_fields_before', $this ); |
28 | 28 | |
29 | - foreach( $this->search_fields as $search_field ) { |
|
29 | + foreach ( $this->search_fields as $search_field ) { |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @action `gravityview_search_widget_field_before` Before each search input is rendered (other than the submit button) |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | do_action( 'gravityview_search_widget_field_before', $this, $search_field ); |
37 | 37 | |
38 | 38 | $gravityview_view->search_field = $search_field; |
39 | - $this->render( 'search-field', $search_field['input'], false ); |
|
39 | + $this->render( 'search-field', $search_field[ 'input' ], false ); |
|
40 | 40 | |
41 | 41 | // show/hide the search button if there are input type fields |
42 | - if( !$has_inputs && $search_field['input'] != 'link' ) { |
|
42 | + if ( ! $has_inputs && $search_field[ 'input' ] != 'link' ) { |
|
43 | 43 | $has_inputs = true; |
44 | 44 | } |
45 | 45 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | do_action( 'gravityview_search_widget_fields_after', $this ); |
59 | 59 | |
60 | - if( $has_inputs ) { |
|
60 | + if ( $has_inputs ) { |
|
61 | 61 | $this->render( 'search-field', 'submit', false ); |
62 | 62 | } |
63 | 63 | ?> |