@@ -2,70 +2,70 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmEntriesController { |
4 | 4 | |
5 | - public static function menu() { |
|
5 | + public static function menu() { |
|
6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
7 | 7 | |
8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
8 | + add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
9 | 9 | |
10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
12 | 12 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' ); |
13 | 13 | add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' ); |
14 | 14 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
15 | - } |
|
16 | - } |
|
15 | + } |
|
16 | + } |
|
17 | 17 | |
18 | - /* Display in Back End */ |
|
19 | - public static function route() { |
|
18 | + /* Display in Back End */ |
|
19 | + public static function route() { |
|
20 | 20 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
21 | 21 | |
22 | - switch ( $action ) { |
|
23 | - case 'show': |
|
24 | - case 'destroy': |
|
25 | - case 'destroy_all': |
|
26 | - return self::$action(); |
|
22 | + switch ( $action ) { |
|
23 | + case 'show': |
|
24 | + case 'destroy': |
|
25 | + case 'destroy_all': |
|
26 | + return self::$action(); |
|
27 | 27 | |
28 | - default: |
|
29 | - do_action( 'frm_entry_action_route', $action ); |
|
30 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
31 | - return; |
|
32 | - } |
|
28 | + default: |
|
29 | + do_action( 'frm_entry_action_route', $action ); |
|
30 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
31 | + return; |
|
32 | + } |
|
33 | 33 | |
34 | - return self::display_list(); |
|
35 | - } |
|
36 | - } |
|
34 | + return self::display_list(); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | public static function contextual_help( $help, $screen_id, $screen ) { |
39 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
40 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
41 | - return $help; |
|
42 | - } |
|
39 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
40 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
41 | + return $help; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
45 | 45 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
46 | 46 | if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) { |
47 | - return $help; |
|
48 | - } |
|
47 | + return $help; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | unset( $action, $page ); |
51 | 51 | |
52 | - $screen->add_help_tab( array( |
|
53 | - 'id' => 'formidable-entries-tab', |
|
54 | - 'title' => __( 'Overview', 'formidable' ), |
|
52 | + $screen->add_help_tab( array( |
|
53 | + 'id' => 'formidable-entries-tab', |
|
54 | + 'title' => __( 'Overview', 'formidable' ), |
|
55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
56 | - )); |
|
56 | + )); |
|
57 | 57 | |
58 | - $screen->set_help_sidebar( |
|
58 | + $screen->set_help_sidebar( |
|
59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
60 | 60 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
61 | 61 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
62 | - ); |
|
62 | + ); |
|
63 | 63 | |
64 | - return $help; |
|
65 | - } |
|
64 | + return $help; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | public static function manage_columns( $columns ) { |
68 | - global $frm_vars; |
|
68 | + global $frm_vars; |
|
69 | 69 | $form_id = FrmForm::get_current_form_id(); |
70 | 70 | |
71 | 71 | $columns[ $form_id . '_id' ] = 'ID'; |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
84 | 84 | self::maybe_add_ip_col( $form_id, $columns ); |
85 | 85 | |
86 | - $frm_vars['cols'] = $columns; |
|
86 | + $frm_vars['cols'] = $columns; |
|
87 | 87 | |
88 | 88 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
89 | 89 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
90 | 90 | add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) ); |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - return $columns; |
|
94 | - } |
|
93 | + return $columns; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | private static function get_columns_for_form( $form_id, &$columns ) { |
97 | 97 | $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
@@ -141,76 +141,76 @@ discard block |
||
141 | 141 | $menu_name = FrmAppHelper::get_menu_name(); |
142 | 142 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
143 | 143 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
144 | - return $check; |
|
145 | - } |
|
144 | + return $check; |
|
145 | + } |
|
146 | 146 | |
147 | 147 | if ( empty( $prev_value ) ) { |
148 | 148 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
149 | 149 | } |
150 | 150 | |
151 | - global $frm_vars; |
|
152 | - //add a check so we don't create a loop |
|
153 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
151 | + global $frm_vars; |
|
152 | + //add a check so we don't create a loop |
|
153 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
154 | 154 | |
155 | - return $check; |
|
156 | - } |
|
155 | + return $check; |
|
156 | + } |
|
157 | 157 | |
158 | - //add hidden columns back from other forms |
|
158 | + //add hidden columns back from other forms |
|
159 | 159 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
160 | 160 | $menu_name = FrmAppHelper::get_menu_name(); |
161 | 161 | $sanitized = sanitize_title( $menu_name ); |
162 | 162 | $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
163 | 163 | if ( $meta_key != $this_page_name ) { |
164 | - return; |
|
165 | - } |
|
166 | - |
|
167 | - global $frm_vars; |
|
168 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
169 | - return; //don't continue if there's no previous value |
|
170 | - } |
|
171 | - |
|
172 | - foreach ( $meta_value as $mk => $mv ) { |
|
173 | - //remove blank values |
|
174 | - if ( empty( $mv ) ) { |
|
175 | - unset( $meta_value[ $mk ] ); |
|
176 | - } |
|
177 | - } |
|
178 | - |
|
179 | - $cur_form_prefix = reset($meta_value); |
|
180 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
181 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
182 | - $save = false; |
|
183 | - |
|
184 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
164 | + return; |
|
165 | + } |
|
166 | + |
|
167 | + global $frm_vars; |
|
168 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
169 | + return; //don't continue if there's no previous value |
|
170 | + } |
|
171 | + |
|
172 | + foreach ( $meta_value as $mk => $mv ) { |
|
173 | + //remove blank values |
|
174 | + if ( empty( $mv ) ) { |
|
175 | + unset( $meta_value[ $mk ] ); |
|
176 | + } |
|
177 | + } |
|
178 | + |
|
179 | + $cur_form_prefix = reset($meta_value); |
|
180 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
181 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
182 | + $save = false; |
|
183 | + |
|
184 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
185 | 185 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
186 | - //don't add blank cols or process included cols |
|
187 | - continue; |
|
188 | - } |
|
186 | + //don't add blank cols or process included cols |
|
187 | + continue; |
|
188 | + } |
|
189 | 189 | |
190 | 190 | $form_prefix = explode( '_', $prev_hidden ); |
191 | - $form_prefix = $form_prefix[0]; |
|
192 | - if ( $form_prefix == $cur_form_prefix ) { |
|
193 | - //don't add back columns that are meant to be hidden |
|
194 | - continue; |
|
195 | - } |
|
191 | + $form_prefix = $form_prefix[0]; |
|
192 | + if ( $form_prefix == $cur_form_prefix ) { |
|
193 | + //don't add back columns that are meant to be hidden |
|
194 | + continue; |
|
195 | + } |
|
196 | 196 | |
197 | - $meta_value[] = $prev_hidden; |
|
198 | - $save = true; |
|
199 | - unset($form_prefix); |
|
200 | - } |
|
197 | + $meta_value[] = $prev_hidden; |
|
198 | + $save = true; |
|
199 | + unset($form_prefix); |
|
200 | + } |
|
201 | 201 | |
202 | 202 | if ( $save ) { |
203 | - $user = wp_get_current_user(); |
|
203 | + $user = wp_get_current_user(); |
|
204 | 204 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
205 | - } |
|
206 | - } |
|
205 | + } |
|
206 | + } |
|
207 | 207 | |
208 | 208 | public static function save_per_page( $save, $option, $value ) { |
209 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
210 | - $save = (int) $value; |
|
211 | - } |
|
212 | - return $save; |
|
213 | - } |
|
209 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
210 | + $save = (int) $value; |
|
211 | + } |
|
212 | + return $save; |
|
213 | + } |
|
214 | 214 | |
215 | 215 | public static function sortable_columns() { |
216 | 216 | $form_id = FrmForm::get_current_form_id(); |
@@ -236,46 +236,46 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | public static function hidden_columns( $result ) { |
239 | - global $frm_vars; |
|
239 | + global $frm_vars; |
|
240 | 240 | |
241 | 241 | $form_id = FrmForm::get_current_form_id(); |
242 | 242 | |
243 | - $return = false; |
|
244 | - foreach ( (array) $result as $r ) { |
|
245 | - if ( ! empty( $r ) ) { |
|
246 | - $form_prefix = explode( '_', $r ); |
|
247 | - $form_prefix = $form_prefix[0]; |
|
243 | + $return = false; |
|
244 | + foreach ( (array) $result as $r ) { |
|
245 | + if ( ! empty( $r ) ) { |
|
246 | + $form_prefix = explode( '_', $r ); |
|
247 | + $form_prefix = $form_prefix[0]; |
|
248 | 248 | |
249 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
250 | - $return = true; |
|
251 | - break; |
|
252 | - } |
|
249 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
250 | + $return = true; |
|
251 | + break; |
|
252 | + } |
|
253 | 253 | |
254 | - unset($form_prefix); |
|
255 | - } |
|
256 | - } |
|
254 | + unset($form_prefix); |
|
255 | + } |
|
256 | + } |
|
257 | 257 | |
258 | - if ( $return ) { |
|
258 | + if ( $return ) { |
|
259 | 259 | return $result; |
260 | 260 | } |
261 | 261 | |
262 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
263 | - $max_columns = 8; |
|
264 | - if ( $i <= $max_columns ) { |
|
262 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
263 | + $max_columns = 8; |
|
264 | + if ( $i <= $max_columns ) { |
|
265 | 265 | return $result; |
266 | 266 | } |
267 | 267 | |
268 | - global $frm_vars; |
|
269 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
270 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
271 | - } |
|
268 | + global $frm_vars; |
|
269 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
270 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
271 | + } |
|
272 | 272 | |
273 | 273 | $has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ); |
274 | 274 | if ( $has_custom_hidden_columns ) { |
275 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
276 | - } else { |
|
277 | - $cols = $frm_vars['cols']; |
|
278 | - $cols = array_reverse($cols, true); |
|
275 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
276 | + } else { |
|
277 | + $cols = $frm_vars['cols']; |
|
278 | + $cols = array_reverse($cols, true); |
|
279 | 279 | |
280 | 280 | if ( $form_id ) { |
281 | 281 | $result[] = $form_id . '_id'; |
@@ -283,59 +283,59 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | $result[] = $form_id . '_item_key'; |
286 | - $i--; |
|
286 | + $i--; |
|
287 | 287 | |
288 | 288 | foreach ( $cols as $col_key => $col ) { |
289 | - if ( $i > $max_columns ) { |
|
289 | + if ( $i > $max_columns ) { |
|
290 | 290 | $result[] = $col_key; |
291 | 291 | } |
292 | - //remove some columns by default |
|
293 | - $i--; |
|
294 | - unset($col_key, $col); |
|
295 | - } |
|
296 | - } |
|
292 | + //remove some columns by default |
|
293 | + $i--; |
|
294 | + unset($col_key, $col); |
|
295 | + } |
|
296 | + } |
|
297 | 297 | |
298 | - return $result; |
|
299 | - } |
|
298 | + return $result; |
|
299 | + } |
|
300 | 300 | |
301 | 301 | public static function display_list( $message = '', $errors = array() ) { |
302 | - global $wpdb, $frm_vars; |
|
302 | + global $wpdb, $frm_vars; |
|
303 | 303 | |
304 | 304 | $form = FrmForm::maybe_get_current_form(); |
305 | 305 | $params = FrmForm::get_admin_params( $form ); |
306 | 306 | |
307 | - if ( $form ) { |
|
308 | - $params['form'] = $form->id; |
|
309 | - $frm_vars['current_form'] = $form; |
|
307 | + if ( $form ) { |
|
308 | + $params['form'] = $form->id; |
|
309 | + $frm_vars['current_form'] = $form; |
|
310 | 310 | |
311 | 311 | self::get_delete_form_time( $form, $errors ); |
312 | 312 | } |
313 | 313 | |
314 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
314 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
315 | 315 | |
316 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
316 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
317 | 317 | |
318 | - $pagenum = $wp_list_table->get_pagenum(); |
|
318 | + $pagenum = $wp_list_table->get_pagenum(); |
|
319 | 319 | |
320 | - $wp_list_table->prepare_items(); |
|
320 | + $wp_list_table->prepare_items(); |
|
321 | 321 | |
322 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
323 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
322 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
323 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
324 | 324 | $url = add_query_arg( 'paged', $total_pages ); |
325 | - if ( headers_sent() ) { |
|
326 | - echo FrmAppHelper::js_redirect($url); |
|
327 | - } else { |
|
328 | - wp_redirect( esc_url_raw( $url ) ); |
|
329 | - } |
|
330 | - die(); |
|
331 | - } |
|
332 | - |
|
333 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
334 | - $message = __( 'Your import is complete', 'formidable' ); |
|
335 | - } |
|
325 | + if ( headers_sent() ) { |
|
326 | + echo FrmAppHelper::js_redirect($url); |
|
327 | + } else { |
|
328 | + wp_redirect( esc_url_raw( $url ) ); |
|
329 | + } |
|
330 | + die(); |
|
331 | + } |
|
332 | + |
|
333 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
334 | + $message = __( 'Your import is complete', 'formidable' ); |
|
335 | + } |
|
336 | 336 | |
337 | 337 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
338 | - } |
|
338 | + } |
|
339 | 339 | |
340 | 340 | private static function get_delete_form_time( $form, &$errors ) { |
341 | 341 | if ( 'trash' == $form->status ) { |
@@ -345,19 +345,19 @@ discard block |
||
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
348 | - /* Back End CRUD */ |
|
348 | + /* Back End CRUD */ |
|
349 | 349 | public static function show( $id = 0 ) { |
350 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
350 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
351 | 351 | |
352 | - if ( ! $id ) { |
|
352 | + if ( ! $id ) { |
|
353 | 353 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
354 | 354 | |
355 | - if ( ! $id ) { |
|
355 | + if ( ! $id ) { |
|
356 | 356 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
357 | - } |
|
358 | - } |
|
357 | + } |
|
358 | + } |
|
359 | 359 | |
360 | - $entry = FrmEntry::getOne($id, true); |
|
360 | + $entry = FrmEntry::getOne($id, true); |
|
361 | 361 | if ( ! $entry ) { |
362 | 362 | echo '<div id="form_show_entry_page" class="wrap">' . |
363 | 363 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -365,110 +365,110 @@ discard block |
||
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | - $data = maybe_unserialize($entry->description); |
|
368 | + $data = maybe_unserialize($entry->description); |
|
369 | 369 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
370 | 370 | $data = array( 'referrer' => $data ); |
371 | 371 | } |
372 | 372 | |
373 | 373 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
374 | - $to_emails = array(); |
|
374 | + $to_emails = array(); |
|
375 | 375 | |
376 | 376 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
377 | - } |
|
377 | + } |
|
378 | 378 | |
379 | - public static function destroy() { |
|
380 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
379 | + public static function destroy() { |
|
380 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
381 | 381 | |
382 | 382 | $params = FrmForm::get_admin_params(); |
383 | 383 | |
384 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
385 | - //unlink entry from post |
|
386 | - global $wpdb; |
|
384 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
385 | + //unlink entry from post |
|
386 | + global $wpdb; |
|
387 | 387 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
388 | - } |
|
388 | + } |
|
389 | 389 | |
390 | - $message = ''; |
|
391 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
392 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
393 | - } |
|
390 | + $message = ''; |
|
391 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
392 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
393 | + } |
|
394 | 394 | |
395 | - self::display_list( $message ); |
|
396 | - } |
|
395 | + self::display_list( $message ); |
|
396 | + } |
|
397 | 397 | |
398 | - public static function destroy_all() { |
|
399 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
400 | - $frm_settings = FrmAppHelper::get_settings(); |
|
401 | - wp_die( $frm_settings->admin_permission ); |
|
402 | - } |
|
398 | + public static function destroy_all() { |
|
399 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
400 | + $frm_settings = FrmAppHelper::get_settings(); |
|
401 | + wp_die( $frm_settings->admin_permission ); |
|
402 | + } |
|
403 | 403 | |
404 | - global $wpdb; |
|
404 | + global $wpdb; |
|
405 | 405 | $params = FrmForm::get_admin_params(); |
406 | - $message = ''; |
|
407 | - $errors = array(); |
|
408 | - $form_id = (int) $params['form']; |
|
406 | + $message = ''; |
|
407 | + $errors = array(); |
|
408 | + $form_id = (int) $params['form']; |
|
409 | 409 | |
410 | - if ( $form_id ) { |
|
411 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
410 | + if ( $form_id ) { |
|
411 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
412 | 412 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
413 | 413 | |
414 | - if ( $action ) { |
|
415 | - // this action takes a while, so only trigger it if there are posts to delete |
|
416 | - foreach ( $entry_ids as $entry_id ) { |
|
417 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
418 | - unset( $entry_id ); |
|
419 | - } |
|
420 | - } |
|
421 | - |
|
422 | - $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
423 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
424 | - if ( $results ) { |
|
414 | + if ( $action ) { |
|
415 | + // this action takes a while, so only trigger it if there are posts to delete |
|
416 | + foreach ( $entry_ids as $entry_id ) { |
|
417 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
418 | + unset( $entry_id ); |
|
419 | + } |
|
420 | + } |
|
421 | + |
|
422 | + $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
423 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
424 | + if ( $results ) { |
|
425 | 425 | FrmEntry::clear_cache(); |
426 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
427 | - } |
|
428 | - } else { |
|
429 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
430 | - } |
|
431 | - |
|
432 | - self::display_list( $message, $errors ); |
|
433 | - } |
|
434 | - |
|
435 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
436 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
437 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
438 | - } |
|
439 | - |
|
440 | - public static function get_form( $filename, $form, $title, $description ) { |
|
441 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
442 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
443 | - } |
|
444 | - |
|
445 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
426 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
427 | + } |
|
428 | + } else { |
|
429 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
430 | + } |
|
431 | + |
|
432 | + self::display_list( $message, $errors ); |
|
433 | + } |
|
434 | + |
|
435 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
436 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
437 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
438 | + } |
|
439 | + |
|
440 | + public static function get_form( $filename, $form, $title, $description ) { |
|
441 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
442 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
443 | + } |
|
444 | + |
|
445 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
446 | 446 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
447 | 447 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
448 | - return; |
|
449 | - } |
|
448 | + return; |
|
449 | + } |
|
450 | 450 | |
451 | - global $frm_vars; |
|
451 | + global $frm_vars; |
|
452 | 452 | |
453 | 453 | $form = FrmForm::getOne( $form_id ); |
454 | - if ( ! $form ) { |
|
455 | - return; |
|
456 | - } |
|
454 | + if ( ! $form ) { |
|
455 | + return; |
|
456 | + } |
|
457 | 457 | |
458 | 458 | $params = FrmForm::get_params( $form ); |
459 | 459 | |
460 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
461 | - $frm_vars['form_params'] = array(); |
|
462 | - } |
|
460 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
461 | + $frm_vars['form_params'] = array(); |
|
462 | + } |
|
463 | 463 | $frm_vars['form_params'][ $form->id ] = $params; |
464 | 464 | |
465 | 465 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
466 | - return; |
|
467 | - } |
|
466 | + return; |
|
467 | + } |
|
468 | 468 | |
469 | - if ( $errors == '' && ! $ajax ) { |
|
469 | + if ( $errors == '' && ! $ajax ) { |
|
470 | 470 | $errors = FrmEntryValidate::validate( $_POST ); |
471 | - } |
|
471 | + } |
|
472 | 472 | |
473 | 473 | /** |
474 | 474 | * Use this filter to add trigger actions and add errors after |
@@ -479,39 +479,39 @@ discard block |
||
479 | 479 | |
480 | 480 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
481 | 481 | |
482 | - if ( empty( $errors ) ) { |
|
482 | + if ( empty( $errors ) ) { |
|
483 | 483 | $_POST['frm_skip_cookie'] = 1; |
484 | - if ( $params['action'] == 'create' ) { |
|
484 | + if ( $params['action'] == 'create' ) { |
|
485 | 485 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
486 | 486 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
487 | - } |
|
488 | - } |
|
487 | + } |
|
488 | + } |
|
489 | 489 | |
490 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
490 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
491 | 491 | unset( $_POST['frm_skip_cookie'] ); |
492 | - } |
|
493 | - } |
|
494 | - |
|
495 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
496 | - self::_delete_entry( $atts['id'], $form ); |
|
497 | - return $url; |
|
498 | - } |
|
499 | - |
|
500 | - //Delete entry if not redirected |
|
501 | - public static function delete_entry_after_save( $atts ) { |
|
502 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
503 | - } |
|
504 | - |
|
505 | - private static function _delete_entry( $entry_id, $form ) { |
|
506 | - if ( ! $form ) { |
|
507 | - return; |
|
508 | - } |
|
509 | - |
|
510 | - $form->options = maybe_unserialize( $form->options ); |
|
511 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
512 | - FrmEntry::destroy( $entry_id ); |
|
513 | - } |
|
514 | - } |
|
492 | + } |
|
493 | + } |
|
494 | + |
|
495 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
496 | + self::_delete_entry( $atts['id'], $form ); |
|
497 | + return $url; |
|
498 | + } |
|
499 | + |
|
500 | + //Delete entry if not redirected |
|
501 | + public static function delete_entry_after_save( $atts ) { |
|
502 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
503 | + } |
|
504 | + |
|
505 | + private static function _delete_entry( $entry_id, $form ) { |
|
506 | + if ( ! $form ) { |
|
507 | + return; |
|
508 | + } |
|
509 | + |
|
510 | + $form->options = maybe_unserialize( $form->options ); |
|
511 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
512 | + FrmEntry::destroy( $entry_id ); |
|
513 | + } |
|
514 | + } |
|
515 | 515 | |
516 | 516 | /** |
517 | 517 | * @param $atts |
@@ -566,15 +566,15 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | public static function entry_sidebar( $entry ) { |
569 | - $data = maybe_unserialize($entry->description); |
|
570 | - $date_format = get_option('date_format'); |
|
571 | - $time_format = get_option('time_format'); |
|
569 | + $data = maybe_unserialize($entry->description); |
|
570 | + $date_format = get_option('date_format'); |
|
571 | + $time_format = get_option('time_format'); |
|
572 | 572 | if ( isset( $data['browser'] ) ) { |
573 | 573 | $browser = FrmEntriesHelper::get_browser( $data['browser'] ); |
574 | 574 | } |
575 | 575 | |
576 | 576 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
577 | - } |
|
577 | + } |
|
578 | 578 | |
579 | 579 | /*********************************************************************** |
580 | 580 | * Deprecated Functions |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | public static function menu() { |
6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
7 | 7 | |
8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
8 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
9 | 9 | |
10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'id' => 'formidable-entries-tab', |
54 | 54 | 'title' => __( 'Overview', 'formidable' ), |
55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
56 | - )); |
|
56 | + ) ); |
|
57 | 57 | |
58 | 58 | $screen->set_help_sidebar( |
59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
@@ -68,19 +68,19 @@ discard block |
||
68 | 68 | global $frm_vars; |
69 | 69 | $form_id = FrmForm::get_current_form_id(); |
70 | 70 | |
71 | - $columns[ $form_id . '_id' ] = 'ID'; |
|
72 | - $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
|
71 | + $columns[$form_id . '_id'] = 'ID'; |
|
72 | + $columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' ); |
|
73 | 73 | |
74 | 74 | if ( $form_id ) { |
75 | 75 | self::get_columns_for_form( $form_id, $columns ); |
76 | 76 | } else { |
77 | - $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' ); |
|
78 | - $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' ); |
|
79 | - $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' ); |
|
77 | + $columns[$form_id . '_form_id'] = __( 'Form', 'formidable' ); |
|
78 | + $columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' ); |
|
79 | + $columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' ); |
|
80 | 80 | } |
81 | 81 | |
82 | - $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
83 | - $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
82 | + $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' ); |
|
83 | + $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' ); |
|
84 | 84 | self::maybe_add_ip_col( $form_id, $columns ); |
85 | 85 | |
86 | 86 | $frm_vars['cols'] = $columns; |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | if ( $sub_form_cols ) { |
108 | 108 | foreach ( $sub_form_cols as $k => $sub_form_col ) { |
109 | 109 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
110 | - unset( $sub_form_cols[ $k ] ); |
|
110 | + unset( $sub_form_cols[$k] ); |
|
111 | 111 | continue; |
112 | 112 | } |
113 | - $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
114 | - unset($sub_form_col); |
|
113 | + $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
114 | + unset( $sub_form_col ); |
|
115 | 115 | } |
116 | 116 | } |
117 | - unset($sub_form_cols); |
|
117 | + unset( $sub_form_cols ); |
|
118 | 118 | } else { |
119 | 119 | $col_id = $form_col->field_key; |
120 | 120 | if ( $form_col->form_id != $form_id ) { |
@@ -124,16 +124,16 @@ discard block |
||
124 | 124 | $has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' ); |
125 | 125 | $is_post_status = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status'; |
126 | 126 | if ( $has_separate_value && ! $is_post_status ) { |
127 | - $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
127 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
128 | 128 | } |
129 | - $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
129 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | 134 | private static function maybe_add_ip_col( $form_id, &$columns ) { |
135 | 135 | if ( FrmAppHelper::ips_saved() ) { |
136 | - $columns[ $form_id . '_ip' ] = 'IP'; |
|
136 | + $columns[$form_id . '_ip'] = 'IP'; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | global $frm_vars; |
152 | 152 | //add a check so we don't create a loop |
153 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
153 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
154 | 154 | |
155 | 155 | return $check; |
156 | 156 | } |
@@ -165,19 +165,19 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | global $frm_vars; |
168 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
168 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
169 | 169 | return; //don't continue if there's no previous value |
170 | 170 | } |
171 | 171 | |
172 | 172 | foreach ( $meta_value as $mk => $mv ) { |
173 | 173 | //remove blank values |
174 | 174 | if ( empty( $mv ) ) { |
175 | - unset( $meta_value[ $mk ] ); |
|
175 | + unset( $meta_value[$mk] ); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - $cur_form_prefix = reset($meta_value); |
|
180 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
179 | + $cur_form_prefix = reset( $meta_value ); |
|
180 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
181 | 181 | $cur_form_prefix = $cur_form_prefix[0]; |
182 | 182 | $save = false; |
183 | 183 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $meta_value[] = $prev_hidden; |
198 | 198 | $save = true; |
199 | - unset($form_prefix); |
|
199 | + unset( $form_prefix ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | if ( $save ) { |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | foreach ( $fields as $field ) { |
229 | 229 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
230 | 230 | // Can't sort on checkboxes because they are stored serialized, or post fields |
231 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
231 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | break; |
252 | 252 | } |
253 | 253 | |
254 | - unset($form_prefix); |
|
254 | + unset( $form_prefix ); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | return $result; |
260 | 260 | } |
261 | 261 | |
262 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
262 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
263 | 263 | $max_columns = 8; |
264 | 264 | if ( $i <= $max_columns ) { |
265 | 265 | return $result; |
266 | 266 | } |
267 | 267 | |
268 | 268 | global $frm_vars; |
269 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
270 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
269 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
270 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | $has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ); |
@@ -275,23 +275,23 @@ discard block |
||
275 | 275 | $result = $frm_vars['current_form']->options['hidden_cols']; |
276 | 276 | } else { |
277 | 277 | $cols = $frm_vars['cols']; |
278 | - $cols = array_reverse($cols, true); |
|
278 | + $cols = array_reverse( $cols, true ); |
|
279 | 279 | |
280 | 280 | if ( $form_id ) { |
281 | 281 | $result[] = $form_id . '_id'; |
282 | - $i--; |
|
282 | + $i --; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | $result[] = $form_id . '_item_key'; |
286 | - $i--; |
|
286 | + $i --; |
|
287 | 287 | |
288 | 288 | foreach ( $cols as $col_key => $col ) { |
289 | 289 | if ( $i > $max_columns ) { |
290 | 290 | $result[] = $col_key; |
291 | 291 | } |
292 | 292 | //remove some columns by default |
293 | - $i--; |
|
294 | - unset($col_key, $col); |
|
293 | + $i --; |
|
294 | + unset( $col_key, $col ); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
324 | 324 | $url = add_query_arg( 'paged', $total_pages ); |
325 | 325 | if ( headers_sent() ) { |
326 | - echo FrmAppHelper::js_redirect($url); |
|
326 | + echo FrmAppHelper::js_redirect( $url ); |
|
327 | 327 | } else { |
328 | 328 | wp_redirect( esc_url_raw( $url ) ); |
329 | 329 | } |
330 | 330 | die(); |
331 | 331 | } |
332 | 332 | |
333 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
333 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
334 | 334 | $message = __( 'Your import is complete', 'formidable' ); |
335 | 335 | } |
336 | 336 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | |
348 | 348 | /* Back End CRUD */ |
349 | 349 | public static function show( $id = 0 ) { |
350 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
350 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
351 | 351 | |
352 | 352 | if ( ! $id ) { |
353 | 353 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
360 | - $entry = FrmEntry::getOne($id, true); |
|
360 | + $entry = FrmEntry::getOne( $id, true ); |
|
361 | 361 | if ( ! $entry ) { |
362 | 362 | echo '<div id="form_show_entry_page" class="wrap">' . |
363 | 363 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | - $data = maybe_unserialize($entry->description); |
|
368 | + $data = maybe_unserialize( $entry->description ); |
|
369 | 369 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
370 | 370 | $data = array( 'referrer' => $data ); |
371 | 371 | } |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | public static function destroy() { |
380 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
380 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
381 | 381 | |
382 | 382 | $params = FrmForm::get_admin_params(); |
383 | 383 | |
384 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
384 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
385 | 385 | //unlink entry from post |
386 | 386 | global $wpdb; |
387 | 387 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -460,9 +460,9 @@ discard block |
||
460 | 460 | if ( ! isset( $frm_vars['form_params'] ) ) { |
461 | 461 | $frm_vars['form_params'] = array(); |
462 | 462 | } |
463 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
463 | + $frm_vars['form_params'][$form->id] = $params; |
|
464 | 464 | |
465 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
465 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
466 | 466 | return; |
467 | 467 | } |
468 | 468 | |
@@ -477,13 +477,13 @@ discard block |
||
477 | 477 | */ |
478 | 478 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
479 | 479 | |
480 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
480 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
481 | 481 | |
482 | 482 | if ( empty( $errors ) ) { |
483 | 483 | $_POST['frm_skip_cookie'] = 1; |
484 | 484 | if ( $params['action'] == 'create' ) { |
485 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
486 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
485 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
486 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
@@ -566,9 +566,9 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | public static function entry_sidebar( $entry ) { |
569 | - $data = maybe_unserialize($entry->description); |
|
570 | - $date_format = get_option('date_format'); |
|
571 | - $time_format = get_option('time_format'); |
|
569 | + $data = maybe_unserialize( $entry->description ); |
|
570 | + $date_format = get_option( 'date_format' ); |
|
571 | + $time_format = get_option( 'time_format' ); |
|
572 | 572 | if ( isset( $data['browser'] ) ) { |
573 | 573 | $browser = FrmEntriesHelper::get_browser( $data['browser'] ); |
574 | 574 | } |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | if ( $this->include_field_in_content( $field_value ) ) { |
376 | 376 | |
377 | 377 | $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() ); |
378 | - $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value; |
|
378 | + $output[$this->get_key_or_id( $field_value )] = $displayed_value; |
|
379 | 379 | |
380 | 380 | if ( $displayed_value !== $field_value->get_saved_value() ) { |
381 | - $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value(); |
|
381 | + $output[$this->get_key_or_id( $field_value ) . '-value'] = $field_value->get_saved_value(); |
|
382 | 382 | } |
383 | 383 | } |
384 | 384 | } |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | |
634 | 634 | if ( is_array( $value ) ) { |
635 | 635 | foreach ( $value as $key => $single_value ) { |
636 | - $value[ $key ] = $this->strip_html( $single_value ); |
|
636 | + $value[$key] = $this->strip_html( $single_value ); |
|
637 | 637 | } |
638 | 638 | } else if ( $this->is_plain_text && ! is_array( $value ) ) { |
639 | 639 | if ( strpos( $value, '<img' ) !== false ) { |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @since 2.04 |
365 | 365 | * |
366 | - * @param array $field_values |
|
366 | + * @param FrmFieldValue[] $field_values |
|
367 | 367 | * @param array $output |
368 | 368 | */ |
369 | 369 | protected function push_field_values_to_array( $field_values, &$output ) { |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @param mixed $value |
572 | 572 | * |
573 | - * @return mixed|string |
|
573 | + * @return FrmFieldValue |
|
574 | 574 | */ |
575 | 575 | protected function prepare_display_value_for_array( $value ) { |
576 | 576 | return $this->strip_html( $value ); |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * @param mixed $display_value |
586 | 586 | * @param string $field_type |
587 | 587 | * |
588 | - * @return mixed|string |
|
588 | + * @return string |
|
589 | 589 | */ |
590 | 590 | protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) { |
591 | 591 | $display_value = $this->flatten_array( $display_value ); |
@@ -6,10 +6,10 @@ discard block |
||
6 | 6 | protected $field; |
7 | 7 | |
8 | 8 | public function prepare_items() { |
9 | - global $per_page; |
|
9 | + global $per_page; |
|
10 | 10 | |
11 | 11 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); |
12 | - $form_id = $this->params['form']; |
|
12 | + $form_id = $this->params['form']; |
|
13 | 13 | |
14 | 14 | $default_orderby = 'id'; |
15 | 15 | $default_order = 'DESC'; |
@@ -25,27 +25,27 @@ discard block |
||
25 | 25 | |
26 | 26 | $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
27 | 27 | |
28 | - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
29 | - $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
30 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
31 | - } |
|
28 | + if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
29 | + $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
30 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | $s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) ); |
34 | 34 | |
35 | - $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
37 | - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
35 | + $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
36 | + if ( strpos($orderby, 'meta') !== false ) { |
|
37 | + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | $order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order; |
42 | 42 | $order = ' ORDER BY ' . $orderby . ' ' . $order; |
43 | 43 | |
44 | - $page = $this->get_pagenum(); |
|
44 | + $page = $this->get_pagenum(); |
|
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | 47 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, $join_form_in_query ); |
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
48 | + $total_items = FrmEntry::getRecordCount($s_query); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -54,19 +54,19 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function no_items() { |
57 | - $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
58 | - if ( ! empty($s) ) { |
|
59 | - _e( 'No Entries Found', 'formidable' ); |
|
60 | - return; |
|
61 | - } |
|
57 | + $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
58 | + if ( ! empty($s) ) { |
|
59 | + _e( 'No Entries Found', 'formidable' ); |
|
60 | + return; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | $form_id = $this->params['form']; |
64 | 64 | $form = $this->params['form']; |
65 | 65 | |
66 | - if ( $form_id ) { |
|
67 | - $form = FrmForm::getOne($form_id); |
|
68 | - } |
|
69 | - $colspan = $this->get_column_count(); |
|
66 | + if ( $form_id ) { |
|
67 | + $form = FrmForm::getOne($form_id); |
|
68 | + } |
|
69 | + $colspan = $this->get_column_count(); |
|
70 | 70 | |
71 | 71 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
72 | 72 | } |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets the name of the primary column in the Entries screen |
|
90 | - * |
|
91 | - * @since 2.0.14 |
|
92 | - * |
|
93 | - * @return string $primary_column |
|
94 | - */ |
|
89 | + * Gets the name of the primary column in the Entries screen |
|
90 | + * |
|
91 | + * @since 2.0.14 |
|
92 | + * |
|
93 | + * @return string $primary_column |
|
94 | + */ |
|
95 | 95 | protected function get_primary_column_name() { |
96 | 96 | $columns = get_column_headers( $this->screen ); |
97 | 97 | $hidden = get_hidden_columns( $this->screen ); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | $this->get_actions( $actions, $item, $view_link ); |
117 | 117 | |
118 | - $action_links = $this->row_actions( $actions ); |
|
118 | + $action_links = $this->row_actions( $actions ); |
|
119 | 119 | |
120 | 120 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
121 | 121 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $r = "<tr id='item-action-{$item->id}'$style>"; |
124 | 124 | |
125 | 125 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
126 | - $action_col = false; |
|
126 | + $action_col = false; |
|
127 | 127 | |
128 | 128 | foreach ( $columns as $column_name => $column_display_name ) { |
129 | 129 | $class = $column_name . ' column-' . $column_name; |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | if ( in_array( $column_name, $hidden ) ) { |
136 | 136 | $class .= ' frm_hidden'; |
137 | 137 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
138 | - $action_col = $column_name; |
|
139 | - } |
|
138 | + $action_col = $column_name; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
142 | 142 | unset($class); |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | $val = $this->column_value( $item ); |
155 | 155 | } |
156 | 156 | |
157 | - $r .= "<td $attributes>"; |
|
157 | + $r .= "<td $attributes>"; |
|
158 | 158 | if ( $column_name == $action_col ) { |
159 | 159 | $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
160 | 160 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
161 | - $r .= $action_links; |
|
161 | + $r .= $action_links; |
|
162 | 162 | } else { |
163 | - $r .= $val; |
|
164 | - } |
|
165 | - $r .= '</td>'; |
|
163 | + $r .= $val; |
|
164 | + } |
|
165 | + $r .= '</td>'; |
|
166 | 166 | } |
167 | 167 | unset($val); |
168 | 168 | } |
@@ -215,19 +215,19 @@ discard block |
||
215 | 215 | return $val; |
216 | 216 | } |
217 | 217 | |
218 | - /** |
|
219 | - * @param string $view_link |
|
220 | - */ |
|
221 | - private function get_actions( &$actions, $item, $view_link ) { |
|
218 | + /** |
|
219 | + * @param string $view_link |
|
220 | + */ |
|
221 | + private function get_actions( &$actions, $item, $view_link ) { |
|
222 | 222 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
223 | 223 | |
224 | - if ( current_user_can('frm_delete_entries') ) { |
|
224 | + if ( current_user_can('frm_delete_entries') ) { |
|
225 | 225 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
226 | 226 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
230 | - } |
|
229 | + $actions = apply_filters('frm_row_actions', $actions, $item); |
|
230 | + } |
|
231 | 231 | |
232 | 232 | private function get_column_value( $item, &$val ) { |
233 | 233 | $col_name = $this->column_name; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $join_form_in_query = true; |
24 | 24 | } |
25 | 25 | |
26 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
26 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
27 | 27 | |
28 | 28 | if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
29 | 29 | $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) ); |
34 | 34 | |
35 | 35 | $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
36 | + if ( strpos( $orderby, 'meta' ) !== false ) { |
|
37 | 37 | $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | 39 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | 47 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, $join_form_in_query ); |
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
48 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | public function no_items() { |
57 | 57 | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
58 | - if ( ! empty($s) ) { |
|
58 | + if ( ! empty( $s ) ) { |
|
59 | 59 | _e( 'No Entries Found', 'formidable' ); |
60 | 60 | return; |
61 | 61 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $form = $this->params['form']; |
65 | 65 | |
66 | 66 | if ( $form_id ) { |
67 | - $form = FrmForm::getOne($form_id); |
|
67 | + $form = FrmForm::getOne( $form_id ); |
|
68 | 68 | } |
69 | 69 | $colspan = $this->get_column_count(); |
70 | 70 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $r = "<tr id='item-action-{$item->id}'$style>"; |
124 | 124 | |
125 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
125 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
126 | 126 | $action_col = false; |
127 | 127 | |
128 | 128 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
142 | - unset($class); |
|
142 | + unset( $class ); |
|
143 | 143 | $attributes .= ' data-colname="' . $column_display_name . '"'; |
144 | 144 | |
145 | 145 | $form_id = $this->params['form'] ? $this->params['form'] : 0; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | $r .= '</td>'; |
166 | 166 | } |
167 | - unset($val); |
|
167 | + unset( $val ); |
|
168 | 168 | } |
169 | 169 | $r .= '</tr>'; |
170 | 170 | |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | private function get_actions( &$actions, $item, $view_link ) { |
222 | 222 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
223 | 223 | |
224 | - if ( current_user_can('frm_delete_entries') ) { |
|
224 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
225 | 225 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
226 | 226 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
227 | 227 | } |
228 | 228 | |
229 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
229 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | private function get_column_value( $item, &$val ) { |
@@ -57,6 +57,9 @@ discard block |
||
57 | 57 | return get_option('blogname'); |
58 | 58 | } |
59 | 59 | |
60 | + /** |
|
61 | + * @param string $url |
|
62 | + */ |
|
60 | 63 | public static function make_affiliate_url( $url ) { |
61 | 64 | $affiliate_id = self::get_affiliate(); |
62 | 65 | if ( ! empty( $affiliate_id ) ) { |
@@ -66,6 +69,9 @@ discard block |
||
66 | 69 | return $url; |
67 | 70 | } |
68 | 71 | |
72 | + /** |
|
73 | + * @return string |
|
74 | + */ |
|
69 | 75 | public static function get_affiliate() { |
70 | 76 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
71 | 77 | } |
@@ -358,7 +364,7 @@ discard block |
||
358 | 364 | * Sanitize the value, and allow some HTML |
359 | 365 | * @since 2.0 |
360 | 366 | * @param string $value |
361 | - * @param array $allowed |
|
367 | + * @param string[] $allowed |
|
362 | 368 | * @return string |
363 | 369 | */ |
364 | 370 | public static function kses( $value, $allowed = array() ) { |
@@ -466,6 +472,7 @@ discard block |
||
466 | 472 | /** |
467 | 473 | * Keep track of the keys cached in each group so they can be deleted |
468 | 474 | * in Redis and Memcache |
475 | + * @param string $group |
|
469 | 476 | */ |
470 | 477 | public static function add_key_to_group_cache( $key, $group ) { |
471 | 478 | $cached = self::get_group_cached_keys( $group ); |
@@ -786,6 +793,9 @@ discard block |
||
786 | 793 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
787 | 794 | } |
788 | 795 | |
796 | + /** |
|
797 | + * @param string $function |
|
798 | + */ |
|
789 | 799 | public static function recursive_function_map( $value, $function ) { |
790 | 800 | if ( is_array( $value ) ) { |
791 | 801 | $original_function = $function; |
@@ -1218,6 +1228,9 @@ discard block |
||
1218 | 1228 | return $sub . (($len < $original_len) ? $continue : ''); |
1219 | 1229 | } |
1220 | 1230 | |
1231 | + /** |
|
1232 | + * @param string[] $function_names |
|
1233 | + */ |
|
1221 | 1234 | public static function mb_function( $function_names, $args ) { |
1222 | 1235 | $mb_function_name = $function_names[0]; |
1223 | 1236 | $function_name = $function_names[1]; |
@@ -1251,6 +1264,9 @@ discard block |
||
1251 | 1264 | return $formatted; |
1252 | 1265 | } |
1253 | 1266 | |
1267 | + /** |
|
1268 | + * @param string $time_format |
|
1269 | + */ |
|
1254 | 1270 | private static function add_time_to_date( $time_format, $date ) { |
1255 | 1271 | if ( empty( $time_format ) ) { |
1256 | 1272 | $time_format = get_option('time_format'); |
@@ -12,50 +12,50 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public static $plug_version = '2.05.02b1'; |
14 | 14 | |
15 | - /** |
|
16 | - * @since 1.07.02 |
|
17 | - * |
|
18 | - * @param none |
|
19 | - * @return string The version of this plugin |
|
20 | - */ |
|
21 | - public static function plugin_version() { |
|
22 | - return self::$plug_version; |
|
23 | - } |
|
24 | - |
|
25 | - public static function plugin_folder() { |
|
26 | - return basename(self::plugin_path()); |
|
27 | - } |
|
28 | - |
|
29 | - public static function plugin_path() { |
|
30 | - return dirname(dirname(dirname(__FILE__))); |
|
31 | - } |
|
32 | - |
|
33 | - public static function plugin_url() { |
|
34 | - //prevously FRM_URL constant |
|
15 | + /** |
|
16 | + * @since 1.07.02 |
|
17 | + * |
|
18 | + * @param none |
|
19 | + * @return string The version of this plugin |
|
20 | + */ |
|
21 | + public static function plugin_version() { |
|
22 | + return self::$plug_version; |
|
23 | + } |
|
24 | + |
|
25 | + public static function plugin_folder() { |
|
26 | + return basename(self::plugin_path()); |
|
27 | + } |
|
28 | + |
|
29 | + public static function plugin_path() { |
|
30 | + return dirname(dirname(dirname(__FILE__))); |
|
31 | + } |
|
32 | + |
|
33 | + public static function plugin_url() { |
|
34 | + //prevously FRM_URL constant |
|
35 | 35 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | public static function relative_plugin_url() { |
39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * @return string Site URL |
|
44 | - */ |
|
45 | - public static function site_url() { |
|
46 | - return site_url(); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Get the name of this site |
|
51 | - * Used for [sitename] shortcode |
|
52 | - * |
|
53 | - * @since 2.0 |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public static function site_name() { |
|
57 | - return get_option('blogname'); |
|
58 | - } |
|
42 | + /** |
|
43 | + * @return string Site URL |
|
44 | + */ |
|
45 | + public static function site_url() { |
|
46 | + return site_url(); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Get the name of this site |
|
51 | + * Used for [sitename] shortcode |
|
52 | + * |
|
53 | + * @since 2.0 |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public static function site_name() { |
|
57 | + return get_option('blogname'); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | public static function make_affiliate_url( $url ) { |
61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * Get the Formidable settings |
|
75 | - * |
|
76 | - * @since 2.0 |
|
77 | - * |
|
78 | - * @param None |
|
79 | - * @return FrmSettings $frm_setings |
|
80 | - */ |
|
81 | - public static function get_settings() { |
|
82 | - global $frm_settings; |
|
83 | - if ( empty($frm_settings) ) { |
|
84 | - $frm_settings = new FrmSettings(); |
|
85 | - } |
|
86 | - return $frm_settings; |
|
87 | - } |
|
73 | + /** |
|
74 | + * Get the Formidable settings |
|
75 | + * |
|
76 | + * @since 2.0 |
|
77 | + * |
|
78 | + * @param None |
|
79 | + * @return FrmSettings $frm_setings |
|
80 | + */ |
|
81 | + public static function get_settings() { |
|
82 | + global $frm_settings; |
|
83 | + if ( empty($frm_settings) ) { |
|
84 | + $frm_settings = new FrmSettings(); |
|
85 | + } |
|
86 | + return $frm_settings; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | public static function get_menu_name() { |
90 | 90 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -99,62 +99,62 @@ discard block |
||
99 | 99 | return ! $frm_settings->no_ips; |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Show a message in place of pro features |
|
104 | - * |
|
105 | - * @since 2.0 |
|
106 | - */ |
|
102 | + /** |
|
103 | + * Show a message in place of pro features |
|
104 | + * |
|
105 | + * @since 2.0 |
|
106 | + */ |
|
107 | 107 | public static function update_message() { |
108 | 108 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
109 | - } |
|
110 | - |
|
111 | - public static function pro_is_installed() { |
|
112 | - return apply_filters('frm_pro_installed', false); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Check for certain page in Formidable settings |
|
117 | - * |
|
118 | - * @since 2.0 |
|
119 | - * |
|
120 | - * @param string $page The name of the page to check |
|
121 | - * @return boolean |
|
122 | - */ |
|
109 | + } |
|
110 | + |
|
111 | + public static function pro_is_installed() { |
|
112 | + return apply_filters('frm_pro_installed', false); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Check for certain page in Formidable settings |
|
117 | + * |
|
118 | + * @since 2.0 |
|
119 | + * |
|
120 | + * @param string $page The name of the page to check |
|
121 | + * @return boolean |
|
122 | + */ |
|
123 | 123 | public static function is_admin_page( $page = 'formidable' ) { |
124 | - global $pagenow; |
|
124 | + global $pagenow; |
|
125 | 125 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
126 | - if ( $pagenow ) { |
|
126 | + if ( $pagenow ) { |
|
127 | 127 | return $pagenow == 'admin.php' && $get_page == $page; |
128 | - } |
|
128 | + } |
|
129 | 129 | |
130 | 130 | return is_admin() && $get_page == $page; |
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Check for the form preview page |
|
135 | - * |
|
136 | - * @since 2.0 |
|
137 | - * |
|
138 | - * @param None |
|
139 | - * @return boolean |
|
140 | - */ |
|
141 | - public static function is_preview_page() { |
|
142 | - global $pagenow; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Check for the form preview page |
|
135 | + * |
|
136 | + * @since 2.0 |
|
137 | + * |
|
138 | + * @param None |
|
139 | + * @return boolean |
|
140 | + */ |
|
141 | + public static function is_preview_page() { |
|
142 | + global $pagenow; |
|
143 | 143 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
144 | 144 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Check for ajax except the form preview page |
|
149 | - * |
|
150 | - * @since 2.0 |
|
151 | - * |
|
152 | - * @param None |
|
153 | - * @return boolean |
|
154 | - */ |
|
155 | - public static function doing_ajax() { |
|
156 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
157 | - } |
|
147 | + /** |
|
148 | + * Check for ajax except the form preview page |
|
149 | + * |
|
150 | + * @since 2.0 |
|
151 | + * |
|
152 | + * @param None |
|
153 | + * @return boolean |
|
154 | + */ |
|
155 | + public static function doing_ajax() { |
|
156 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
157 | + } |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * @since 2.0.8 |
@@ -164,102 +164,102 @@ discard block |
||
164 | 164 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
165 | 165 | } |
166 | 166 | |
167 | - /** |
|
168 | - * Check if on an admin page |
|
169 | - * |
|
170 | - * @since 2.0 |
|
171 | - * |
|
172 | - * @param None |
|
173 | - * @return boolean |
|
174 | - */ |
|
175 | - public static function is_admin() { |
|
176 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Check if value contains blank value or empty array |
|
181 | - * |
|
182 | - * @since 2.0 |
|
183 | - * @param mixed $value - value to check |
|
167 | + /** |
|
168 | + * Check if on an admin page |
|
169 | + * |
|
170 | + * @since 2.0 |
|
171 | + * |
|
172 | + * @param None |
|
173 | + * @return boolean |
|
174 | + */ |
|
175 | + public static function is_admin() { |
|
176 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Check if value contains blank value or empty array |
|
181 | + * |
|
182 | + * @since 2.0 |
|
183 | + * @param mixed $value - value to check |
|
184 | 184 | * @param string |
185 | - * @return boolean |
|
186 | - */ |
|
187 | - public static function is_empty_value( $value, $empty = '' ) { |
|
188 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
189 | - } |
|
190 | - |
|
191 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
192 | - return ! self::is_empty_value( $value, $empty ); |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Get any value from the $_SERVER |
|
197 | - * |
|
198 | - * @since 2.0 |
|
199 | - * @param string $value |
|
200 | - * @return string |
|
201 | - */ |
|
185 | + * @return boolean |
|
186 | + */ |
|
187 | + public static function is_empty_value( $value, $empty = '' ) { |
|
188 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
189 | + } |
|
190 | + |
|
191 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
192 | + return ! self::is_empty_value( $value, $empty ); |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Get any value from the $_SERVER |
|
197 | + * |
|
198 | + * @since 2.0 |
|
199 | + * @param string $value |
|
200 | + * @return string |
|
201 | + */ |
|
202 | 202 | public static function get_server_value( $value ) { |
203 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Check for the IP address in several places |
|
208 | - * Used by [ip] shortcode |
|
209 | - * |
|
210 | - * @return string The IP address of the current user |
|
211 | - */ |
|
212 | - public static function get_ip_address() { |
|
203 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Check for the IP address in several places |
|
208 | + * Used by [ip] shortcode |
|
209 | + * |
|
210 | + * @return string The IP address of the current user |
|
211 | + */ |
|
212 | + public static function get_ip_address() { |
|
213 | 213 | $ip = ''; |
214 | - foreach ( array( |
|
215 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
216 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
217 | - ) as $key ) { |
|
218 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
219 | - continue; |
|
220 | - } |
|
221 | - |
|
222 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
223 | - $ip = trim($ip); // just to be safe |
|
224 | - |
|
225 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
226 | - return $ip; |
|
227 | - } |
|
228 | - } |
|
229 | - } |
|
214 | + foreach ( array( |
|
215 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
216 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
217 | + ) as $key ) { |
|
218 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
219 | + continue; |
|
220 | + } |
|
221 | + |
|
222 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
223 | + $ip = trim($ip); // just to be safe |
|
224 | + |
|
225 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
226 | + return $ip; |
|
227 | + } |
|
228 | + } |
|
229 | + } |
|
230 | 230 | |
231 | 231 | return sanitize_text_field( $ip ); |
232 | - } |
|
232 | + } |
|
233 | 233 | |
234 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
235 | - if ( strpos($param, '[') ) { |
|
236 | - $params = explode('[', $param); |
|
237 | - $param = $params[0]; |
|
238 | - } |
|
234 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
235 | + if ( strpos($param, '[') ) { |
|
236 | + $params = explode('[', $param); |
|
237 | + $param = $params[0]; |
|
238 | + } |
|
239 | 239 | |
240 | 240 | if ( $src == 'get' ) { |
241 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
242 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
243 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
244 | - } |
|
241 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
242 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
243 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
244 | + } |
|
245 | 245 | self::sanitize_value( $sanitize, $value ); |
246 | 246 | } else { |
247 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
248 | - } |
|
247 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
248 | + } |
|
249 | 249 | |
250 | 250 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
251 | - foreach ( $params as $k => $p ) { |
|
252 | - if ( ! $k || ! is_array($value) ) { |
|
253 | - continue; |
|
254 | - } |
|
251 | + foreach ( $params as $k => $p ) { |
|
252 | + if ( ! $k || ! is_array($value) ) { |
|
253 | + continue; |
|
254 | + } |
|
255 | 255 | |
256 | - $p = trim($p, ']'); |
|
257 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
258 | - } |
|
259 | - } |
|
256 | + $p = trim($p, ']'); |
|
257 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
258 | + } |
|
259 | + } |
|
260 | 260 | |
261 | - return $value; |
|
262 | - } |
|
261 | + return $value; |
|
262 | + } |
|
263 | 263 | |
264 | 264 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
265 | 265 | return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
277 | 277 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
278 | - } |
|
278 | + } |
|
279 | 279 | |
280 | 280 | /** |
281 | 281 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
314 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
315 | - * |
|
316 | - * @since 2.0.8 |
|
317 | - * @param string $value |
|
318 | - * @return string $value |
|
319 | - */ |
|
314 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
315 | + * |
|
316 | + * @since 2.0.8 |
|
317 | + * @param string $value |
|
318 | + * @return string $value |
|
319 | + */ |
|
320 | 320 | public static function preserve_backslashes( $value ) { |
321 | 321 | // If backslashes have already been added, don't add them again |
322 | 322 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
342 | - $temp_values = $values; |
|
343 | - foreach ( $temp_values as $k => $val ) { |
|
344 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
341 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
342 | + $temp_values = $values; |
|
343 | + foreach ( $temp_values as $k => $val ) { |
|
344 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
345 | 345 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
346 | - } |
|
347 | - } |
|
348 | - } |
|
346 | + } |
|
347 | + } |
|
348 | + } |
|
349 | 349 | |
350 | 350 | public static function sanitize_array( &$values ) { |
351 | 351 | $temp_values = $values; |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public static function kses( $value, $allowed = array() ) { |
365 | 365 | $html = array( |
366 | - 'a' => array( |
|
366 | + 'a' => array( |
|
367 | 367 | 'href' => array(), |
368 | 368 | 'title' => array(), |
369 | 369 | 'id' => array(), |
370 | 370 | 'class' => array(), |
371 | - ), |
|
371 | + ), |
|
372 | 372 | ); |
373 | 373 | |
374 | 374 | $allowed_html = array(); |
@@ -379,77 +379,77 @@ discard block |
||
379 | 379 | return wp_kses( $value, $allowed_html ); |
380 | 380 | } |
381 | 381 | |
382 | - /** |
|
383 | - * Used when switching the action for a bulk action |
|
384 | - * @since 2.0 |
|
385 | - */ |
|
386 | - public static function remove_get_action() { |
|
387 | - if ( ! isset($_GET) ) { |
|
388 | - return; |
|
389 | - } |
|
382 | + /** |
|
383 | + * Used when switching the action for a bulk action |
|
384 | + * @since 2.0 |
|
385 | + */ |
|
386 | + public static function remove_get_action() { |
|
387 | + if ( ! isset($_GET) ) { |
|
388 | + return; |
|
389 | + } |
|
390 | 390 | |
391 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
392 | - if ( ! empty( $new_action ) ) { |
|
391 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
392 | + if ( ! empty( $new_action ) ) { |
|
393 | 393 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
394 | - } |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Check the WP query for a parameter |
|
399 | - * |
|
400 | - * @since 2.0 |
|
401 | - * @return string|array |
|
402 | - */ |
|
403 | - public static function get_query_var( $value, $param ) { |
|
404 | - if ( $value != '' ) { |
|
405 | - return $value; |
|
406 | - } |
|
407 | - |
|
408 | - global $wp_query; |
|
409 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
410 | - $value = $wp_query->query_vars[ $param ]; |
|
411 | - } |
|
412 | - |
|
413 | - return $value; |
|
414 | - } |
|
415 | - |
|
416 | - /** |
|
417 | - * @param string $type |
|
418 | - */ |
|
419 | - public static function trigger_hook_load( $type, $object = null ) { |
|
420 | - // only load the form hooks once |
|
394 | + } |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * Check the WP query for a parameter |
|
399 | + * |
|
400 | + * @since 2.0 |
|
401 | + * @return string|array |
|
402 | + */ |
|
403 | + public static function get_query_var( $value, $param ) { |
|
404 | + if ( $value != '' ) { |
|
405 | + return $value; |
|
406 | + } |
|
407 | + |
|
408 | + global $wp_query; |
|
409 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
410 | + $value = $wp_query->query_vars[ $param ]; |
|
411 | + } |
|
412 | + |
|
413 | + return $value; |
|
414 | + } |
|
415 | + |
|
416 | + /** |
|
417 | + * @param string $type |
|
418 | + */ |
|
419 | + public static function trigger_hook_load( $type, $object = null ) { |
|
420 | + // only load the form hooks once |
|
421 | 421 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
422 | - if ( ! $hooks_loaded ) { |
|
422 | + if ( ! $hooks_loaded ) { |
|
423 | 423 | do_action( 'frm_load_' . $type . '_hooks' ); |
424 | - } |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
428 | - * Check cache before fetching values and saving to cache |
|
429 | - * |
|
430 | - * @since 2.0 |
|
431 | - * |
|
432 | - * @param string $cache_key The unique name for this cache |
|
433 | - * @param string $group The name of the cache group |
|
434 | - * @param string $query If blank, don't run a db call |
|
435 | - * @param string $type The wpdb function to use with this query |
|
436 | - * @return mixed $results The cache or query results |
|
437 | - */ |
|
438 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
439 | - $results = wp_cache_get($cache_key, $group); |
|
440 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
441 | - return $results; |
|
442 | - } |
|
443 | - |
|
444 | - if ( 'get_posts' == $type ) { |
|
445 | - $results = get_posts($query); |
|
424 | + } |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | + * Check cache before fetching values and saving to cache |
|
429 | + * |
|
430 | + * @since 2.0 |
|
431 | + * |
|
432 | + * @param string $cache_key The unique name for this cache |
|
433 | + * @param string $group The name of the cache group |
|
434 | + * @param string $query If blank, don't run a db call |
|
435 | + * @param string $type The wpdb function to use with this query |
|
436 | + * @return mixed $results The cache or query results |
|
437 | + */ |
|
438 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
439 | + $results = wp_cache_get($cache_key, $group); |
|
440 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
441 | + return $results; |
|
442 | + } |
|
443 | + |
|
444 | + if ( 'get_posts' == $type ) { |
|
445 | + $results = get_posts($query); |
|
446 | 446 | } else if ( 'get_associative_results' == $type ) { |
447 | 447 | global $wpdb; |
448 | 448 | $results = $wpdb->get_results( $query, OBJECT_K ); |
449 | - } else { |
|
450 | - global $wpdb; |
|
451 | - $results = $wpdb->{$type}($query); |
|
452 | - } |
|
449 | + } else { |
|
450 | + global $wpdb; |
|
451 | + $results = $wpdb->{$type}($query); |
|
452 | + } |
|
453 | 453 | |
454 | 454 | self::set_cache( $cache_key, $results, $group, $time ); |
455 | 455 | |
@@ -482,44 +482,44 @@ discard block |
||
482 | 482 | return $cached; |
483 | 483 | } |
484 | 484 | |
485 | - /** |
|
486 | - * Data that should be stored for a long time can be stored in a transient. |
|
487 | - * First check the cache, then check the transient |
|
488 | - * @since 2.0 |
|
489 | - * @return mixed The cached value or false |
|
490 | - */ |
|
485 | + /** |
|
486 | + * Data that should be stored for a long time can be stored in a transient. |
|
487 | + * First check the cache, then check the transient |
|
488 | + * @since 2.0 |
|
489 | + * @return mixed The cached value or false |
|
490 | + */ |
|
491 | 491 | public static function check_cache_and_transient( $cache_key ) { |
492 | - // check caching layer first |
|
493 | - $results = self::check_cache( $cache_key ); |
|
494 | - if ( $results ) { |
|
495 | - return $results; |
|
496 | - } |
|
497 | - |
|
498 | - // then check the transient |
|
499 | - $results = get_transient($cache_key); |
|
500 | - if ( $results ) { |
|
501 | - wp_cache_set($cache_key, $results); |
|
502 | - } |
|
503 | - |
|
504 | - return $results; |
|
505 | - } |
|
506 | - |
|
507 | - /** |
|
508 | - * @since 2.0 |
|
509 | - * @param string $cache_key |
|
510 | - */ |
|
492 | + // check caching layer first |
|
493 | + $results = self::check_cache( $cache_key ); |
|
494 | + if ( $results ) { |
|
495 | + return $results; |
|
496 | + } |
|
497 | + |
|
498 | + // then check the transient |
|
499 | + $results = get_transient($cache_key); |
|
500 | + if ( $results ) { |
|
501 | + wp_cache_set($cache_key, $results); |
|
502 | + } |
|
503 | + |
|
504 | + return $results; |
|
505 | + } |
|
506 | + |
|
507 | + /** |
|
508 | + * @since 2.0 |
|
509 | + * @param string $cache_key |
|
510 | + */ |
|
511 | 511 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
512 | 512 | delete_transient($cache_key); |
513 | 513 | wp_cache_delete( $cache_key, $group ); |
514 | 514 | } |
515 | 515 | |
516 | - /** |
|
517 | - * Delete all caching in a single group |
|
518 | - * |
|
519 | - * @since 2.0 |
|
520 | - * |
|
521 | - * @param string $group The name of the cache group |
|
522 | - */ |
|
516 | + /** |
|
517 | + * Delete all caching in a single group |
|
518 | + * |
|
519 | + * @since 2.0 |
|
520 | + * |
|
521 | + * @param string $group The name of the cache group |
|
522 | + */ |
|
523 | 523 | public static function cache_delete_group( $group ) { |
524 | 524 | $cached_keys = self::get_group_cached_keys( $group ); |
525 | 525 | |
@@ -532,34 +532,34 @@ discard block |
||
532 | 532 | } |
533 | 533 | } |
534 | 534 | |
535 | - /** |
|
536 | - * Check a value from a shortcode to see if true or false. |
|
537 | - * True when value is 1, true, 'true', 'yes' |
|
538 | - * |
|
539 | - * @since 1.07.10 |
|
540 | - * |
|
541 | - * @param string $value The value to compare |
|
542 | - * @return boolean True or False |
|
543 | - */ |
|
535 | + /** |
|
536 | + * Check a value from a shortcode to see if true or false. |
|
537 | + * True when value is 1, true, 'true', 'yes' |
|
538 | + * |
|
539 | + * @since 1.07.10 |
|
540 | + * |
|
541 | + * @param string $value The value to compare |
|
542 | + * @return boolean True or False |
|
543 | + */ |
|
544 | 544 | public static function is_true( $value ) { |
545 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
546 | - } |
|
545 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
546 | + } |
|
547 | 547 | |
548 | - /** |
|
549 | - * Used to filter shortcode in text widgets |
|
550 | - */ |
|
551 | - public static function widget_text_filter_callback( $matches ) { |
|
552 | - return do_shortcode( $matches[0] ); |
|
553 | - } |
|
548 | + /** |
|
549 | + * Used to filter shortcode in text widgets |
|
550 | + */ |
|
551 | + public static function widget_text_filter_callback( $matches ) { |
|
552 | + return do_shortcode( $matches[0] ); |
|
553 | + } |
|
554 | 554 | |
555 | - public static function get_pages() { |
|
555 | + public static function get_pages() { |
|
556 | 556 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
557 | - } |
|
557 | + } |
|
558 | 558 | |
559 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
560 | - $pages = self::get_pages(); |
|
559 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
560 | + $pages = self::get_pages(); |
|
561 | 561 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
562 | - ?> |
|
562 | + ?> |
|
563 | 563 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
564 | 564 | <option value=""> </option> |
565 | 565 | <?php foreach ( $pages as $page ) { ?> |
@@ -569,108 +569,108 @@ discard block |
||
569 | 569 | <?php } ?> |
570 | 570 | </select> |
571 | 571 | <?php |
572 | - } |
|
572 | + } |
|
573 | 573 | |
574 | 574 | public static function post_edit_link( $post_id ) { |
575 | - $post = get_post($post_id); |
|
576 | - if ( $post ) { |
|
575 | + $post = get_post($post_id); |
|
576 | + if ( $post ) { |
|
577 | 577 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
578 | 578 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
579 | - } |
|
580 | - return ''; |
|
581 | - } |
|
579 | + } |
|
580 | + return ''; |
|
581 | + } |
|
582 | 582 | |
583 | 583 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
584 | - ?> |
|
584 | + ?> |
|
585 | 585 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
586 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
587 | - ?> class="frm_multiselect"> |
|
586 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
587 | + ?> class="frm_multiselect"> |
|
588 | 588 | <?php self::roles_options($capability); ?> |
589 | 589 | </select> |
590 | 590 | <?php |
591 | - } |
|
591 | + } |
|
592 | 592 | |
593 | 593 | public static function roles_options( $capability ) { |
594 | - global $frm_vars; |
|
595 | - if ( isset($frm_vars['editable_roles']) ) { |
|
596 | - $editable_roles = $frm_vars['editable_roles']; |
|
597 | - } else { |
|
598 | - $editable_roles = get_editable_roles(); |
|
599 | - $frm_vars['editable_roles'] = $editable_roles; |
|
600 | - } |
|
601 | - |
|
602 | - foreach ( $editable_roles as $role => $details ) { |
|
603 | - $name = translate_user_role($details['name'] ); ?> |
|
594 | + global $frm_vars; |
|
595 | + if ( isset($frm_vars['editable_roles']) ) { |
|
596 | + $editable_roles = $frm_vars['editable_roles']; |
|
597 | + } else { |
|
598 | + $editable_roles = get_editable_roles(); |
|
599 | + $frm_vars['editable_roles'] = $editable_roles; |
|
600 | + } |
|
601 | + |
|
602 | + foreach ( $editable_roles as $role => $details ) { |
|
603 | + $name = translate_user_role($details['name'] ); ?> |
|
604 | 604 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
605 | 605 | <?php |
606 | - unset($role, $details); |
|
607 | - } |
|
608 | - } |
|
606 | + unset($role, $details); |
|
607 | + } |
|
608 | + } |
|
609 | 609 | |
610 | 610 | public static function frm_capabilities( $type = 'auto' ) { |
611 | - $cap = array( |
|
612 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
613 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
614 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
615 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
616 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
617 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
618 | - ); |
|
611 | + $cap = array( |
|
612 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
613 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
614 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
615 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
616 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
617 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
618 | + ); |
|
619 | 619 | |
620 | 620 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
621 | - return $cap; |
|
622 | - } |
|
621 | + return $cap; |
|
622 | + } |
|
623 | 623 | |
624 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
625 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
626 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
627 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
624 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
625 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
626 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
627 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
628 | 628 | |
629 | - return $cap; |
|
630 | - } |
|
629 | + return $cap; |
|
630 | + } |
|
631 | 631 | |
632 | 632 | public static function user_has_permission( $needed_role ) { |
633 | - if ( $needed_role == '-1' ) { |
|
634 | - return false; |
|
633 | + if ( $needed_role == '-1' ) { |
|
634 | + return false; |
|
635 | 635 | } |
636 | 636 | |
637 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
638 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
639 | - return true; |
|
640 | - } |
|
637 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
638 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
639 | + return true; |
|
640 | + } |
|
641 | 641 | |
642 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
643 | - foreach ( $roles as $role ) { |
|
642 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
643 | + foreach ( $roles as $role ) { |
|
644 | 644 | if ( current_user_can( $role ) ) { |
645 | - return true; |
|
645 | + return true; |
|
646 | 646 | } |
647 | - if ( $role == $needed_role ) { |
|
648 | - break; |
|
647 | + if ( $role == $needed_role ) { |
|
648 | + break; |
|
649 | 649 | } |
650 | - } |
|
651 | - return false; |
|
652 | - } |
|
653 | - |
|
654 | - /** |
|
655 | - * Make sure administrators can see Formidable menu |
|
656 | - * |
|
657 | - * @since 2.0 |
|
658 | - */ |
|
659 | - public static function maybe_add_permissions() { |
|
650 | + } |
|
651 | + return false; |
|
652 | + } |
|
653 | + |
|
654 | + /** |
|
655 | + * Make sure administrators can see Formidable menu |
|
656 | + * |
|
657 | + * @since 2.0 |
|
658 | + */ |
|
659 | + public static function maybe_add_permissions() { |
|
660 | 660 | self::force_capability( 'frm_view_entries' ); |
661 | 661 | |
662 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
663 | - return; |
|
664 | - } |
|
662 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
663 | + return; |
|
664 | + } |
|
665 | 665 | |
666 | 666 | $user_id = get_current_user_id(); |
667 | 667 | $user = new WP_User( $user_id ); |
668 | - $frm_roles = self::frm_capabilities(); |
|
669 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
668 | + $frm_roles = self::frm_capabilities(); |
|
669 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
670 | 670 | $user->add_cap( $frm_role ); |
671 | - unset($frm_role, $frm_role_description); |
|
672 | - } |
|
673 | - } |
|
671 | + unset($frm_role, $frm_role_description); |
|
672 | + } |
|
673 | + } |
|
674 | 674 | |
675 | 675 | /** |
676 | 676 | * Make sure admins have permission to see the menu items |
@@ -686,28 +686,28 @@ discard block |
||
686 | 686 | } |
687 | 687 | } |
688 | 688 | |
689 | - /** |
|
690 | - * Check if the user has permision for action. |
|
691 | - * Return permission message and stop the action if no permission |
|
692 | - * @since 2.0 |
|
693 | - * @param string $permission |
|
694 | - */ |
|
689 | + /** |
|
690 | + * Check if the user has permision for action. |
|
691 | + * Return permission message and stop the action if no permission |
|
692 | + * @since 2.0 |
|
693 | + * @param string $permission |
|
694 | + */ |
|
695 | 695 | public static function permission_check( $permission, $show_message = 'show' ) { |
696 | - $permission_error = self::permission_nonce_error($permission); |
|
697 | - if ( $permission_error !== false ) { |
|
698 | - if ( 'hide' == $show_message ) { |
|
699 | - $permission_error = ''; |
|
700 | - } |
|
701 | - wp_die($permission_error); |
|
702 | - } |
|
703 | - } |
|
704 | - |
|
705 | - /** |
|
706 | - * Check user permission and nonce |
|
707 | - * @since 2.0 |
|
708 | - * @param string $permission |
|
709 | - * @return false|string The permission message or false if allowed |
|
710 | - */ |
|
696 | + $permission_error = self::permission_nonce_error($permission); |
|
697 | + if ( $permission_error !== false ) { |
|
698 | + if ( 'hide' == $show_message ) { |
|
699 | + $permission_error = ''; |
|
700 | + } |
|
701 | + wp_die($permission_error); |
|
702 | + } |
|
703 | + } |
|
704 | + |
|
705 | + /** |
|
706 | + * Check user permission and nonce |
|
707 | + * @since 2.0 |
|
708 | + * @param string $permission |
|
709 | + * @return false|string The permission message or false if allowed |
|
710 | + */ |
|
711 | 711 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
712 | 712 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
713 | 713 | $frm_settings = self::get_settings(); |
@@ -715,23 +715,23 @@ discard block |
||
715 | 715 | } |
716 | 716 | |
717 | 717 | $error = false; |
718 | - if ( empty($nonce_name) ) { |
|
719 | - return $error; |
|
720 | - } |
|
718 | + if ( empty($nonce_name) ) { |
|
719 | + return $error; |
|
720 | + } |
|
721 | 721 | |
722 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
723 | - $frm_settings = self::get_settings(); |
|
724 | - $error = $frm_settings->admin_permission; |
|
725 | - } |
|
722 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
723 | + $frm_settings = self::get_settings(); |
|
724 | + $error = $frm_settings->admin_permission; |
|
725 | + } |
|
726 | 726 | |
727 | - return $error; |
|
728 | - } |
|
727 | + return $error; |
|
728 | + } |
|
729 | 729 | |
730 | - public static function checked( $values, $current ) { |
|
730 | + public static function checked( $values, $current ) { |
|
731 | 731 | if ( self::check_selected( $values, $current ) ) { |
732 | - echo ' checked="checked"'; |
|
732 | + echo ' checked="checked"'; |
|
733 | 733 | } |
734 | - } |
|
734 | + } |
|
735 | 735 | |
736 | 736 | public static function check_selected( $values, $current ) { |
737 | 737 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -741,50 +741,50 @@ discard block |
||
741 | 741 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
742 | 742 | } |
743 | 743 | |
744 | - /** |
|
745 | - * Check if current field option is an "other" option |
|
746 | - * |
|
747 | - * @since 2.0 |
|
748 | - * |
|
749 | - * @param string $opt_key |
|
750 | - * @return boolean Returns true if current field option is an "Other" option |
|
751 | - */ |
|
752 | - public static function is_other_opt( $opt_key ) { |
|
753 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
754 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
755 | - } |
|
756 | - |
|
757 | - /** |
|
758 | - * Get value that belongs in "Other" text box |
|
759 | - * |
|
760 | - * @since 2.0 |
|
761 | - * |
|
762 | - * @param string $opt_key |
|
763 | - * @param array $field |
|
764 | - * @return string $other_val |
|
765 | - */ |
|
766 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
744 | + /** |
|
745 | + * Check if current field option is an "other" option |
|
746 | + * |
|
747 | + * @since 2.0 |
|
748 | + * |
|
749 | + * @param string $opt_key |
|
750 | + * @return boolean Returns true if current field option is an "Other" option |
|
751 | + */ |
|
752 | + public static function is_other_opt( $opt_key ) { |
|
753 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
754 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
755 | + } |
|
756 | + |
|
757 | + /** |
|
758 | + * Get value that belongs in "Other" text box |
|
759 | + * |
|
760 | + * @since 2.0 |
|
761 | + * |
|
762 | + * @param string $opt_key |
|
763 | + * @param array $field |
|
764 | + * @return string $other_val |
|
765 | + */ |
|
766 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
767 | 767 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
768 | 768 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
769 | - } |
|
770 | - |
|
771 | - /** |
|
772 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
773 | - * Intended for front-end use |
|
774 | - * |
|
775 | - * @since 2.0 |
|
776 | - * |
|
777 | - * @param array $field |
|
778 | - * @param boolean $other_opt |
|
779 | - * @param string $checked |
|
780 | - * @param array $args should include opt_key and field name |
|
781 | - * @return string $other_val |
|
782 | - */ |
|
783 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
769 | + } |
|
770 | + |
|
771 | + /** |
|
772 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
773 | + * Intended for front-end use |
|
774 | + * |
|
775 | + * @since 2.0 |
|
776 | + * |
|
777 | + * @param array $field |
|
778 | + * @param boolean $other_opt |
|
779 | + * @param string $checked |
|
780 | + * @param array $args should include opt_key and field name |
|
781 | + * @return string $other_val |
|
782 | + */ |
|
783 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
784 | 784 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
785 | 785 | $args['field'] = $field; |
786 | 786 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
787 | - } |
|
787 | + } |
|
788 | 788 | |
789 | 789 | public static function recursive_function_map( $value, $function ) { |
790 | 790 | if ( is_array( $value ) ) { |
@@ -814,24 +814,24 @@ discard block |
||
814 | 814 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
815 | 815 | } |
816 | 816 | |
817 | - /** |
|
818 | - * Flatten a multi-dimensional array |
|
819 | - */ |
|
817 | + /** |
|
818 | + * Flatten a multi-dimensional array |
|
819 | + */ |
|
820 | 820 | public static function array_flatten( $array, $keys = 'keep' ) { |
821 | - $return = array(); |
|
822 | - foreach ( $array as $key => $value ) { |
|
823 | - if ( is_array($value) ) { |
|
821 | + $return = array(); |
|
822 | + foreach ( $array as $key => $value ) { |
|
823 | + if ( is_array($value) ) { |
|
824 | 824 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
825 | - } else { |
|
825 | + } else { |
|
826 | 826 | if ( $keys == 'keep' ) { |
827 | 827 | $return[ $key ] = $value; |
828 | 828 | } else { |
829 | 829 | $return[] = $value; |
830 | 830 | } |
831 | - } |
|
832 | - } |
|
833 | - return $return; |
|
834 | - } |
|
831 | + } |
|
832 | + } |
|
833 | + return $return; |
|
834 | + } |
|
835 | 835 | |
836 | 836 | public static function esc_textarea( $text, $is_rich_text = false ) { |
837 | 837 | $safe_text = str_replace( '"', '"', $text ); |
@@ -842,38 +842,38 @@ discard block |
||
842 | 842 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
843 | 843 | } |
844 | 844 | |
845 | - /** |
|
846 | - * Add auto paragraphs to text areas |
|
847 | - * @since 2.0 |
|
848 | - */ |
|
845 | + /** |
|
846 | + * Add auto paragraphs to text areas |
|
847 | + * @since 2.0 |
|
848 | + */ |
|
849 | 849 | public static function use_wpautop( $content ) { |
850 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
851 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
852 | - } |
|
853 | - return $content; |
|
854 | - } |
|
850 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
851 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
852 | + } |
|
853 | + return $content; |
|
854 | + } |
|
855 | 855 | |
856 | 856 | public static function replace_quotes( $val ) { |
857 | - //Replace double quotes |
|
857 | + //Replace double quotes |
|
858 | 858 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
859 | - //Replace single quotes |
|
860 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
861 | - return $val; |
|
862 | - } |
|
863 | - |
|
864 | - /** |
|
865 | - * @since 2.0 |
|
866 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
867 | - */ |
|
868 | - public static function jquery_ui_base_url() { |
|
859 | + //Replace single quotes |
|
860 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
861 | + return $val; |
|
862 | + } |
|
863 | + |
|
864 | + /** |
|
865 | + * @since 2.0 |
|
866 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
867 | + */ |
|
868 | + public static function jquery_ui_base_url() { |
|
869 | 869 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
870 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
871 | - return $url; |
|
872 | - } |
|
870 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
871 | + return $url; |
|
872 | + } |
|
873 | 873 | |
874 | - /** |
|
875 | - * @param string $handle |
|
876 | - */ |
|
874 | + /** |
|
875 | + * @param string $handle |
|
876 | + */ |
|
877 | 877 | public static function script_version( $handle, $default = 0 ) { |
878 | 878 | global $wp_scripts; |
879 | 879 | if ( ! $wp_scripts ) { |
@@ -895,241 +895,241 @@ discard block |
||
895 | 895 | |
896 | 896 | public static function js_redirect( $url ) { |
897 | 897 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
898 | - } |
|
898 | + } |
|
899 | 899 | |
900 | 900 | public static function get_user_id_param( $user_id ) { |
901 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
902 | - return $user_id; |
|
903 | - } |
|
901 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
902 | + return $user_id; |
|
903 | + } |
|
904 | 904 | |
905 | 905 | if ( $user_id == 'current' ) { |
906 | 906 | $user_id = get_current_user_id(); |
907 | 907 | } else { |
908 | - if ( is_email($user_id) ) { |
|
909 | - $user = get_user_by('email', $user_id); |
|
910 | - } else { |
|
911 | - $user = get_user_by('login', $user_id); |
|
912 | - } |
|
908 | + if ( is_email($user_id) ) { |
|
909 | + $user = get_user_by('email', $user_id); |
|
910 | + } else { |
|
911 | + $user = get_user_by('login', $user_id); |
|
912 | + } |
|
913 | 913 | |
914 | - if ( $user ) { |
|
915 | - $user_id = $user->ID; |
|
916 | - } |
|
917 | - unset($user); |
|
918 | - } |
|
914 | + if ( $user ) { |
|
915 | + $user_id = $user->ID; |
|
916 | + } |
|
917 | + unset($user); |
|
918 | + } |
|
919 | 919 | |
920 | - return $user_id; |
|
921 | - } |
|
920 | + return $user_id; |
|
921 | + } |
|
922 | 922 | |
923 | 923 | public static function get_file_contents( $filename, $atts = array() ) { |
924 | - if ( ! is_file($filename) ) { |
|
925 | - return false; |
|
926 | - } |
|
927 | - |
|
928 | - extract($atts); |
|
929 | - ob_start(); |
|
930 | - include($filename); |
|
931 | - $contents = ob_get_contents(); |
|
932 | - ob_end_clean(); |
|
933 | - return $contents; |
|
934 | - } |
|
935 | - |
|
936 | - /** |
|
937 | - * @param string $table_name |
|
938 | - * @param string $column |
|
924 | + if ( ! is_file($filename) ) { |
|
925 | + return false; |
|
926 | + } |
|
927 | + |
|
928 | + extract($atts); |
|
929 | + ob_start(); |
|
930 | + include($filename); |
|
931 | + $contents = ob_get_contents(); |
|
932 | + ob_end_clean(); |
|
933 | + return $contents; |
|
934 | + } |
|
935 | + |
|
936 | + /** |
|
937 | + * @param string $table_name |
|
938 | + * @param string $column |
|
939 | 939 | * @param int $id |
940 | 940 | * @param int $num_chars |
941 | - */ |
|
942 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
943 | - $key = ''; |
|
941 | + */ |
|
942 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
943 | + $key = ''; |
|
944 | 944 | |
945 | - if ( ! empty( $name ) ) { |
|
946 | - $key = sanitize_key($name); |
|
947 | - } |
|
945 | + if ( ! empty( $name ) ) { |
|
946 | + $key = sanitize_key($name); |
|
947 | + } |
|
948 | 948 | |
949 | 949 | if ( empty( $key ) ) { |
950 | - $max_slug_value = pow(36, $num_chars); |
|
951 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
952 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
953 | - } |
|
950 | + $max_slug_value = pow(36, $num_chars); |
|
951 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
952 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
953 | + } |
|
954 | 954 | |
955 | 955 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
956 | 956 | $key = $key . 'a'; |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | 959 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
960 | 960 | |
961 | - if ( $key_check || is_numeric($key_check) ) { |
|
962 | - $suffix = 2; |
|
961 | + if ( $key_check || is_numeric($key_check) ) { |
|
962 | + $suffix = 2; |
|
963 | 963 | do { |
964 | 964 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
965 | 965 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
966 | 966 | $suffix++; |
967 | 967 | } while ( $key_check || is_numeric( $key_check ) ); |
968 | 968 | $key = $alt_post_name; |
969 | - } |
|
970 | - return $key; |
|
971 | - } |
|
972 | - |
|
973 | - /** |
|
974 | - * Editing a Form or Entry |
|
975 | - * @param string $table |
|
976 | - * @return bool|array |
|
977 | - */ |
|
978 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
979 | - if ( ! $record ) { |
|
980 | - return false; |
|
981 | - } |
|
982 | - |
|
983 | - if ( empty($post_values) ) { |
|
984 | - $post_values = stripslashes_deep($_POST); |
|
985 | - } |
|
969 | + } |
|
970 | + return $key; |
|
971 | + } |
|
972 | + |
|
973 | + /** |
|
974 | + * Editing a Form or Entry |
|
975 | + * @param string $table |
|
976 | + * @return bool|array |
|
977 | + */ |
|
978 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
979 | + if ( ! $record ) { |
|
980 | + return false; |
|
981 | + } |
|
982 | + |
|
983 | + if ( empty($post_values) ) { |
|
984 | + $post_values = stripslashes_deep($_POST); |
|
985 | + } |
|
986 | 986 | |
987 | 987 | $values = array( 'id' => $record->id, 'fields' => array() ); |
988 | 988 | |
989 | 989 | foreach ( array( 'name', 'description' ) as $var ) { |
990 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
990 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
991 | 991 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
992 | - unset($var, $default_val); |
|
993 | - } |
|
994 | - |
|
995 | - $values['description'] = self::use_wpautop($values['description']); |
|
996 | - $frm_settings = self::get_settings(); |
|
997 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
998 | - |
|
999 | - foreach ( (array) $fields as $field ) { |
|
1000 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
1001 | - if ( ! $is_form_builder ) { |
|
1002 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
1003 | - } |
|
992 | + unset($var, $default_val); |
|
993 | + } |
|
994 | + |
|
995 | + $values['description'] = self::use_wpautop($values['description']); |
|
996 | + $frm_settings = self::get_settings(); |
|
997 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
998 | + |
|
999 | + foreach ( (array) $fields as $field ) { |
|
1000 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
1001 | + if ( ! $is_form_builder ) { |
|
1002 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
1003 | + } |
|
1004 | 1004 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
1005 | 1005 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
1006 | - } |
|
1006 | + } |
|
1007 | 1007 | |
1008 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
1008 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
1009 | 1009 | |
1010 | - if ( $table == 'entries' ) { |
|
1011 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
1012 | - } else if ( $table == 'forms' ) { |
|
1013 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
1014 | - } |
|
1010 | + if ( $table == 'entries' ) { |
|
1011 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
1012 | + } else if ( $table == 'forms' ) { |
|
1013 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
1014 | + } |
|
1015 | 1015 | |
1016 | - return $values; |
|
1017 | - } |
|
1016 | + return $values; |
|
1017 | + } |
|
1018 | 1018 | |
1019 | 1019 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
1020 | - $post_values = $args['post_values']; |
|
1021 | - |
|
1022 | - if ( $args['default'] ) { |
|
1023 | - $meta_value = $field->default_value; |
|
1024 | - } else { |
|
1025 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1026 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1027 | - $field->field_options['custom_field'] = ''; |
|
1028 | - } |
|
1020 | + $post_values = $args['post_values']; |
|
1021 | + |
|
1022 | + if ( $args['default'] ) { |
|
1023 | + $meta_value = $field->default_value; |
|
1024 | + } else { |
|
1025 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1026 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
1027 | + $field->field_options['custom_field'] = ''; |
|
1028 | + } |
|
1029 | 1029 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
1030 | - } else { |
|
1030 | + } else { |
|
1031 | 1031 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
1032 | - } |
|
1033 | - } |
|
1032 | + } |
|
1033 | + } |
|
1034 | 1034 | |
1035 | 1035 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
1036 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1037 | - |
|
1038 | - $field_array = array( |
|
1039 | - 'id' => $field->id, |
|
1040 | - 'value' => $new_value, |
|
1041 | - 'default_value' => $field->default_value, |
|
1042 | - 'name' => $field->name, |
|
1043 | - 'description' => $field->description, |
|
1044 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1045 | - 'options' => $field->options, |
|
1046 | - 'required' => $field->required, |
|
1047 | - 'field_key' => $field->field_key, |
|
1048 | - 'field_order' => $field->field_order, |
|
1049 | - 'form_id' => $field->form_id, |
|
1036 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1037 | + |
|
1038 | + $field_array = array( |
|
1039 | + 'id' => $field->id, |
|
1040 | + 'value' => $new_value, |
|
1041 | + 'default_value' => $field->default_value, |
|
1042 | + 'name' => $field->name, |
|
1043 | + 'description' => $field->description, |
|
1044 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1045 | + 'options' => $field->options, |
|
1046 | + 'required' => $field->required, |
|
1047 | + 'field_key' => $field->field_key, |
|
1048 | + 'field_order' => $field->field_order, |
|
1049 | + 'form_id' => $field->form_id, |
|
1050 | 1050 | 'parent_form_id' => $args['parent_form_id'], |
1051 | - ); |
|
1051 | + ); |
|
1052 | 1052 | |
1053 | - $args['field_type'] = $field_type; |
|
1054 | - self::fill_field_opts($field, $field_array, $args); |
|
1053 | + $args['field_type'] = $field_type; |
|
1054 | + self::fill_field_opts($field, $field_array, $args); |
|
1055 | 1055 | // Track the original field's type |
1056 | 1056 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
1057 | 1057 | |
1058 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
1058 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
1059 | 1059 | |
1060 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1061 | - $field_array['unique_msg'] = ''; |
|
1062 | - } |
|
1060 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1061 | + $field_array['unique_msg'] = ''; |
|
1062 | + } |
|
1063 | 1063 | |
1064 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
1064 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
1065 | 1065 | |
1066 | - $values['fields'][ $field->id ] = $field_array; |
|
1067 | - } |
|
1066 | + $values['fields'][ $field->id ] = $field_array; |
|
1067 | + } |
|
1068 | 1068 | |
1069 | 1069 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1070 | - $post_values = $args['post_values']; |
|
1071 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1070 | + $post_values = $args['post_values']; |
|
1071 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1072 | 1072 | |
1073 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1073 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1074 | 1074 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
1075 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1076 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1077 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1078 | - if ( $args['field_type'] == 'captcha' ) { |
|
1079 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1080 | - } else { |
|
1081 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1082 | - } |
|
1083 | - } |
|
1084 | - } |
|
1085 | - |
|
1086 | - if ( $field_array['custom_html'] == '' ) { |
|
1087 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1088 | - } |
|
1089 | - } |
|
1090 | - |
|
1091 | - /** |
|
1092 | - * @param string $table |
|
1093 | - */ |
|
1075 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1076 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1077 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1078 | + if ( $args['field_type'] == 'captcha' ) { |
|
1079 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1080 | + } else { |
|
1081 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1082 | + } |
|
1083 | + } |
|
1084 | + } |
|
1085 | + |
|
1086 | + if ( $field_array['custom_html'] == '' ) { |
|
1087 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1088 | + } |
|
1089 | + } |
|
1090 | + |
|
1091 | + /** |
|
1092 | + * @param string $table |
|
1093 | + */ |
|
1094 | 1094 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
1095 | - if ( $table == 'entries' ) { |
|
1096 | - $form = $record->form_id; |
|
1095 | + if ( $table == 'entries' ) { |
|
1096 | + $form = $record->form_id; |
|
1097 | 1097 | FrmForm::maybe_get_form( $form ); |
1098 | - } else { |
|
1099 | - $form = $record; |
|
1100 | - } |
|
1098 | + } else { |
|
1099 | + $form = $record; |
|
1100 | + } |
|
1101 | 1101 | |
1102 | - if ( ! $form ) { |
|
1103 | - return; |
|
1104 | - } |
|
1102 | + if ( ! $form ) { |
|
1103 | + return; |
|
1104 | + } |
|
1105 | 1105 | |
1106 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1106 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1107 | 1107 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1108 | 1108 | |
1109 | - if ( ! is_array($form->options) ) { |
|
1110 | - return; |
|
1111 | - } |
|
1109 | + if ( ! is_array($form->options) ) { |
|
1110 | + return; |
|
1111 | + } |
|
1112 | 1112 | |
1113 | - foreach ( $form->options as $opt => $value ) { |
|
1114 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1115 | - } |
|
1113 | + foreach ( $form->options as $opt => $value ) { |
|
1114 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1115 | + } |
|
1116 | 1116 | |
1117 | - self::fill_form_defaults($post_values, $values); |
|
1118 | - } |
|
1117 | + self::fill_form_defaults($post_values, $values); |
|
1118 | + } |
|
1119 | 1119 | |
1120 | - /** |
|
1121 | - * Set to POST value or default |
|
1122 | - */ |
|
1120 | + /** |
|
1121 | + * Set to POST value or default |
|
1122 | + */ |
|
1123 | 1123 | private static function fill_form_defaults( $post_values, array &$values ) { |
1124 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1124 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1125 | 1125 | |
1126 | - foreach ( $form_defaults as $opt => $default ) { |
|
1127 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1126 | + foreach ( $form_defaults as $opt => $default ) { |
|
1127 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1128 | 1128 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
1129 | - } |
|
1129 | + } |
|
1130 | 1130 | |
1131 | - unset($opt, $defaut); |
|
1132 | - } |
|
1131 | + unset($opt, $defaut); |
|
1132 | + } |
|
1133 | 1133 | |
1134 | 1134 | if ( ! isset( $values['custom_style'] ) ) { |
1135 | 1135 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1138,10 +1138,10 @@ discard block |
||
1138 | 1138 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1139 | 1139 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
1140 | 1140 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
1141 | - } |
|
1142 | - unset($h); |
|
1143 | - } |
|
1144 | - } |
|
1141 | + } |
|
1142 | + unset($h); |
|
1143 | + } |
|
1144 | + } |
|
1145 | 1145 | |
1146 | 1146 | /** |
1147 | 1147 | * @since 2.2.10 |
@@ -1164,59 +1164,59 @@ discard block |
||
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | public static function insert_opt_html( $args ) { |
1167 | - $class = ''; |
|
1168 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1169 | - $class .= 'show_frm_not_email_to'; |
|
1170 | - } |
|
1171 | - ?> |
|
1167 | + $class = ''; |
|
1168 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1169 | + $class .= 'show_frm_not_email_to'; |
|
1170 | + } |
|
1171 | + ?> |
|
1172 | 1172 | <li> |
1173 | 1173 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
1174 | 1174 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
1175 | 1175 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
1176 | 1176 | </li> |
1177 | 1177 | <?php |
1178 | - } |
|
1178 | + } |
|
1179 | 1179 | |
1180 | 1180 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
1181 | - if ( is_array( $str ) ) { |
|
1182 | - return ''; |
|
1181 | + if ( is_array( $str ) ) { |
|
1182 | + return ''; |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | - $length = (int) $length; |
|
1185 | + $length = (int) $length; |
|
1186 | 1186 | $str = wp_strip_all_tags( $str ); |
1187 | 1187 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
1188 | 1188 | |
1189 | 1189 | if ( $length == 0 ) { |
1190 | - return ''; |
|
1191 | - } else if ( $length <= 10 ) { |
|
1190 | + return ''; |
|
1191 | + } else if ( $length <= 10 ) { |
|
1192 | 1192 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1193 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1194 | - } |
|
1193 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
1194 | + } |
|
1195 | 1195 | |
1196 | - $sub = ''; |
|
1197 | - $len = 0; |
|
1196 | + $sub = ''; |
|
1197 | + $len = 0; |
|
1198 | 1198 | |
1199 | 1199 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1200 | 1200 | |
1201 | 1201 | foreach ( $words as $word ) { |
1202 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1202 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
1203 | 1203 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1204 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1205 | - break; |
|
1206 | - } |
|
1204 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
1205 | + break; |
|
1206 | + } |
|
1207 | 1207 | |
1208 | - $sub .= $part; |
|
1208 | + $sub .= $part; |
|
1209 | 1209 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1210 | 1210 | |
1211 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1212 | - break; |
|
1213 | - } |
|
1211 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1212 | + break; |
|
1213 | + } |
|
1214 | 1214 | |
1215 | - unset($total_len, $word); |
|
1216 | - } |
|
1215 | + unset($total_len, $word); |
|
1216 | + } |
|
1217 | 1217 | |
1218 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1219 | - } |
|
1218 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
1219 | + } |
|
1220 | 1220 | |
1221 | 1221 | public static function mb_function( $function_names, $args ) { |
1222 | 1222 | $mb_function_name = $function_names[0]; |
@@ -1228,18 +1228,18 @@ discard block |
||
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1231 | - if ( empty($date) ) { |
|
1232 | - return $date; |
|
1233 | - } |
|
1231 | + if ( empty($date) ) { |
|
1232 | + return $date; |
|
1233 | + } |
|
1234 | 1234 | |
1235 | - if ( empty($date_format) ) { |
|
1236 | - $date_format = get_option('date_format'); |
|
1237 | - } |
|
1235 | + if ( empty($date_format) ) { |
|
1236 | + $date_format = get_option('date_format'); |
|
1237 | + } |
|
1238 | 1238 | |
1239 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1240 | - $frmpro_settings = new FrmProSettings(); |
|
1241 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1242 | - } |
|
1239 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1240 | + $frmpro_settings = new FrmProSettings(); |
|
1241 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1242 | + } |
|
1243 | 1243 | |
1244 | 1244 | $formatted = self::get_localized_date( $date_format, $date ); |
1245 | 1245 | |
@@ -1248,8 +1248,8 @@ discard block |
||
1248 | 1248 | $formatted .= self::add_time_to_date( $time_format, $date ); |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - return $formatted; |
|
1252 | - } |
|
1251 | + return $formatted; |
|
1252 | + } |
|
1253 | 1253 | |
1254 | 1254 | private static function add_time_to_date( $time_format, $date ) { |
1255 | 1255 | if ( empty( $time_format ) ) { |
@@ -1331,61 +1331,61 @@ discard block |
||
1331 | 1331 | ); |
1332 | 1332 | } |
1333 | 1333 | |
1334 | - /** |
|
1335 | - * Added for < WP 4.0 compatability |
|
1336 | - * |
|
1337 | - * @since 1.07.10 |
|
1338 | - * |
|
1339 | - * @param string $term The value to escape |
|
1340 | - * @return string The escaped value |
|
1341 | - */ |
|
1334 | + /** |
|
1335 | + * Added for < WP 4.0 compatability |
|
1336 | + * |
|
1337 | + * @since 1.07.10 |
|
1338 | + * |
|
1339 | + * @param string $term The value to escape |
|
1340 | + * @return string The escaped value |
|
1341 | + */ |
|
1342 | 1342 | public static function esc_like( $term ) { |
1343 | - global $wpdb; |
|
1344 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1343 | + global $wpdb; |
|
1344 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
1345 | 1345 | // WP 4.0 |
1346 | - $term = $wpdb->esc_like( $term ); |
|
1347 | - } else { |
|
1348 | - $term = like_escape( $term ); |
|
1349 | - } |
|
1346 | + $term = $wpdb->esc_like( $term ); |
|
1347 | + } else { |
|
1348 | + $term = like_escape( $term ); |
|
1349 | + } |
|
1350 | 1350 | |
1351 | - return $term; |
|
1352 | - } |
|
1351 | + return $term; |
|
1352 | + } |
|
1353 | 1353 | |
1354 | - /** |
|
1355 | - * @param string $order_query |
|
1356 | - */ |
|
1354 | + /** |
|
1355 | + * @param string $order_query |
|
1356 | + */ |
|
1357 | 1357 | public static function esc_order( $order_query ) { |
1358 | - if ( empty($order_query) ) { |
|
1359 | - return ''; |
|
1360 | - } |
|
1361 | - |
|
1362 | - // remove ORDER BY before santizing |
|
1363 | - $order_query = strtolower($order_query); |
|
1364 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1365 | - $order_query = str_replace('order by', '', $order_query); |
|
1366 | - } |
|
1367 | - |
|
1368 | - $order_query = explode(' ', trim($order_query)); |
|
1369 | - |
|
1370 | - $order_fields = array( |
|
1371 | - 'id', 'form_key', 'name', 'description', |
|
1372 | - 'parent_form_id', 'logged_in', 'is_template', |
|
1373 | - 'default_template', 'status', 'created_at', |
|
1374 | - ); |
|
1375 | - |
|
1376 | - $order = trim(trim(reset($order_query), ',')); |
|
1377 | - if ( ! in_array($order, $order_fields) ) { |
|
1378 | - return ''; |
|
1379 | - } |
|
1380 | - |
|
1381 | - $order_by = ''; |
|
1382 | - if ( count($order_query) > 1 ) { |
|
1358 | + if ( empty($order_query) ) { |
|
1359 | + return ''; |
|
1360 | + } |
|
1361 | + |
|
1362 | + // remove ORDER BY before santizing |
|
1363 | + $order_query = strtolower($order_query); |
|
1364 | + if ( strpos($order_query, 'order by') !== false ) { |
|
1365 | + $order_query = str_replace('order by', '', $order_query); |
|
1366 | + } |
|
1367 | + |
|
1368 | + $order_query = explode(' ', trim($order_query)); |
|
1369 | + |
|
1370 | + $order_fields = array( |
|
1371 | + 'id', 'form_key', 'name', 'description', |
|
1372 | + 'parent_form_id', 'logged_in', 'is_template', |
|
1373 | + 'default_template', 'status', 'created_at', |
|
1374 | + ); |
|
1375 | + |
|
1376 | + $order = trim(trim(reset($order_query), ',')); |
|
1377 | + if ( ! in_array($order, $order_fields) ) { |
|
1378 | + return ''; |
|
1379 | + } |
|
1380 | + |
|
1381 | + $order_by = ''; |
|
1382 | + if ( count($order_query) > 1 ) { |
|
1383 | 1383 | $order_by = end( $order_query ); |
1384 | 1384 | self::esc_order_by( $order_by ); |
1385 | - } |
|
1385 | + } |
|
1386 | 1386 | |
1387 | 1387 | return ' ORDER BY ' . $order . ' ' . $order_by; |
1388 | - } |
|
1388 | + } |
|
1389 | 1389 | |
1390 | 1390 | /** |
1391 | 1391 | * Make sure this is ordering by either ASC or DESC |
@@ -1397,169 +1397,169 @@ discard block |
||
1397 | 1397 | } |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - /** |
|
1401 | - * @param string $limit |
|
1402 | - */ |
|
1400 | + /** |
|
1401 | + * @param string $limit |
|
1402 | + */ |
|
1403 | 1403 | public static function esc_limit( $limit ) { |
1404 | - if ( empty($limit) ) { |
|
1405 | - return ''; |
|
1406 | - } |
|
1404 | + if ( empty($limit) ) { |
|
1405 | + return ''; |
|
1406 | + } |
|
1407 | 1407 | |
1408 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1409 | - if ( is_numeric($limit) ) { |
|
1408 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1409 | + if ( is_numeric($limit) ) { |
|
1410 | 1410 | return ' LIMIT ' . $limit; |
1411 | - } |
|
1411 | + } |
|
1412 | 1412 | |
1413 | - $limit = explode(',', trim($limit)); |
|
1414 | - foreach ( $limit as $k => $l ) { |
|
1415 | - if ( is_numeric( $l ) ) { |
|
1416 | - $limit[ $k ] = $l; |
|
1417 | - } |
|
1418 | - } |
|
1413 | + $limit = explode(',', trim($limit)); |
|
1414 | + foreach ( $limit as $k => $l ) { |
|
1415 | + if ( is_numeric( $l ) ) { |
|
1416 | + $limit[ $k ] = $l; |
|
1417 | + } |
|
1418 | + } |
|
1419 | 1419 | |
1420 | - $limit = implode(',', $limit); |
|
1420 | + $limit = implode(',', $limit); |
|
1421 | 1421 | return ' LIMIT ' . $limit; |
1422 | - } |
|
1423 | - |
|
1424 | - /** |
|
1425 | - * Get an array of values ready to go through $wpdb->prepare |
|
1426 | - * @since 2.0 |
|
1427 | - */ |
|
1428 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
1429 | - $placeholders = array_fill(0, count($array), $type); |
|
1430 | - return implode(', ', $placeholders); |
|
1431 | - } |
|
1432 | - |
|
1433 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1434 | - if ( empty($where) ) { |
|
1435 | - return ''; |
|
1436 | - } |
|
1422 | + } |
|
1423 | + |
|
1424 | + /** |
|
1425 | + * Get an array of values ready to go through $wpdb->prepare |
|
1426 | + * @since 2.0 |
|
1427 | + */ |
|
1428 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
1429 | + $placeholders = array_fill(0, count($array), $type); |
|
1430 | + return implode(', ', $placeholders); |
|
1431 | + } |
|
1432 | + |
|
1433 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1434 | + if ( empty($where) ) { |
|
1435 | + return ''; |
|
1436 | + } |
|
1437 | 1437 | |
1438 | 1438 | if ( is_array( $where ) ) { |
1439 | - global $wpdb; |
|
1440 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1439 | + global $wpdb; |
|
1440 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1441 | 1441 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
1442 | 1442 | } else { |
1443 | - $where = $starts_with . $where; |
|
1444 | - } |
|
1443 | + $where = $starts_with . $where; |
|
1444 | + } |
|
1445 | 1445 | |
1446 | - return $where; |
|
1447 | - } |
|
1446 | + return $where; |
|
1447 | + } |
|
1448 | 1448 | |
1449 | - // Pagination Methods |
|
1449 | + // Pagination Methods |
|
1450 | 1450 | |
1451 | - /** |
|
1452 | - * @param integer $current_p |
|
1453 | - */ |
|
1451 | + /** |
|
1452 | + * @param integer $current_p |
|
1453 | + */ |
|
1454 | 1454 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
1455 | 1455 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
1456 | 1456 | } |
1457 | 1457 | |
1458 | - /** |
|
1459 | - * @param integer $current_p |
|
1460 | - */ |
|
1461 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1462 | - if ( $current_p == 1 ) { |
|
1463 | - return 1; |
|
1464 | - } else { |
|
1465 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1466 | - } |
|
1467 | - } |
|
1458 | + /** |
|
1459 | + * @param integer $current_p |
|
1460 | + */ |
|
1461 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1462 | + if ( $current_p == 1 ) { |
|
1463 | + return 1; |
|
1464 | + } else { |
|
1465 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1466 | + } |
|
1467 | + } |
|
1468 | 1468 | |
1469 | 1469 | /** |
1470 | 1470 | * @return array |
1471 | 1471 | */ |
1472 | 1472 | public static function json_to_array( $json_vars ) { |
1473 | - $vars = array(); |
|
1474 | - foreach ( $json_vars as $jv ) { |
|
1475 | - $jv_name = explode('[', $jv['name']); |
|
1476 | - $last = count($jv_name) - 1; |
|
1477 | - foreach ( $jv_name as $p => $n ) { |
|
1478 | - $name = trim($n, ']'); |
|
1479 | - if ( ! isset($l1) ) { |
|
1480 | - $l1 = $name; |
|
1481 | - } |
|
1482 | - |
|
1483 | - if ( ! isset($l2) ) { |
|
1484 | - $l2 = $name; |
|
1485 | - } |
|
1486 | - |
|
1487 | - if ( ! isset($l3) ) { |
|
1488 | - $l3 = $name; |
|
1489 | - } |
|
1490 | - |
|
1491 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1492 | - |
|
1493 | - switch ( $p ) { |
|
1494 | - case 0: |
|
1495 | - $l1 = $name; |
|
1496 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1497 | - break; |
|
1498 | - |
|
1499 | - case 1: |
|
1500 | - $l2 = $name; |
|
1501 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1502 | - break; |
|
1503 | - |
|
1504 | - case 2: |
|
1505 | - $l3 = $name; |
|
1506 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1507 | - break; |
|
1508 | - |
|
1509 | - case 3: |
|
1510 | - $l4 = $name; |
|
1511 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1512 | - break; |
|
1513 | - } |
|
1514 | - |
|
1515 | - unset($this_val, $n); |
|
1516 | - } |
|
1517 | - |
|
1518 | - unset($last, $jv); |
|
1519 | - } |
|
1520 | - |
|
1521 | - return $vars; |
|
1522 | - } |
|
1523 | - |
|
1524 | - /** |
|
1525 | - * @param string $name |
|
1526 | - * @param string $l1 |
|
1527 | - */ |
|
1528 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1529 | - if ( $name == '' ) { |
|
1530 | - $vars[] = $val; |
|
1531 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1532 | - $vars[ $l1 ] = $val; |
|
1533 | - } |
|
1534 | - } |
|
1473 | + $vars = array(); |
|
1474 | + foreach ( $json_vars as $jv ) { |
|
1475 | + $jv_name = explode('[', $jv['name']); |
|
1476 | + $last = count($jv_name) - 1; |
|
1477 | + foreach ( $jv_name as $p => $n ) { |
|
1478 | + $name = trim($n, ']'); |
|
1479 | + if ( ! isset($l1) ) { |
|
1480 | + $l1 = $name; |
|
1481 | + } |
|
1482 | + |
|
1483 | + if ( ! isset($l2) ) { |
|
1484 | + $l2 = $name; |
|
1485 | + } |
|
1486 | + |
|
1487 | + if ( ! isset($l3) ) { |
|
1488 | + $l3 = $name; |
|
1489 | + } |
|
1490 | + |
|
1491 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1492 | + |
|
1493 | + switch ( $p ) { |
|
1494 | + case 0: |
|
1495 | + $l1 = $name; |
|
1496 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1497 | + break; |
|
1498 | + |
|
1499 | + case 1: |
|
1500 | + $l2 = $name; |
|
1501 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1502 | + break; |
|
1503 | + |
|
1504 | + case 2: |
|
1505 | + $l3 = $name; |
|
1506 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1507 | + break; |
|
1508 | + |
|
1509 | + case 3: |
|
1510 | + $l4 = $name; |
|
1511 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1512 | + break; |
|
1513 | + } |
|
1514 | + |
|
1515 | + unset($this_val, $n); |
|
1516 | + } |
|
1517 | + |
|
1518 | + unset($last, $jv); |
|
1519 | + } |
|
1520 | + |
|
1521 | + return $vars; |
|
1522 | + } |
|
1523 | + |
|
1524 | + /** |
|
1525 | + * @param string $name |
|
1526 | + * @param string $l1 |
|
1527 | + */ |
|
1528 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1529 | + if ( $name == '' ) { |
|
1530 | + $vars[] = $val; |
|
1531 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1532 | + $vars[ $l1 ] = $val; |
|
1533 | + } |
|
1534 | + } |
|
1535 | 1535 | |
1536 | 1536 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
1537 | - $tooltips = array( |
|
1538 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1539 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1540 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1541 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1542 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1543 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1544 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1545 | - ); |
|
1546 | - |
|
1547 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1548 | - return; |
|
1549 | - } |
|
1550 | - |
|
1551 | - if ( 'open' == $class ) { |
|
1552 | - echo ' frm_help"'; |
|
1553 | - } else { |
|
1554 | - echo ' class="frm_help"'; |
|
1555 | - } |
|
1537 | + $tooltips = array( |
|
1538 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1539 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1540 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1541 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1542 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1543 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1544 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1545 | + ); |
|
1546 | + |
|
1547 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
1548 | + return; |
|
1549 | + } |
|
1550 | + |
|
1551 | + if ( 'open' == $class ) { |
|
1552 | + echo ' frm_help"'; |
|
1553 | + } else { |
|
1554 | + echo ' class="frm_help"'; |
|
1555 | + } |
|
1556 | 1556 | |
1557 | 1557 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
1558 | 1558 | |
1559 | - if ( 'open' != $class ) { |
|
1560 | - echo '"'; |
|
1561 | - } |
|
1562 | - } |
|
1559 | + if ( 'open' != $class ) { |
|
1560 | + echo '"'; |
|
1561 | + } |
|
1562 | + } |
|
1563 | 1563 | |
1564 | 1564 | /** |
1565 | 1565 | * Add the current_page class to that page in the form nav |
@@ -1575,35 +1575,35 @@ discard block |
||
1575 | 1575 | } |
1576 | 1576 | } |
1577 | 1577 | |
1578 | - /** |
|
1579 | - * Prepare and json_encode post content |
|
1580 | - * |
|
1581 | - * @since 2.0 |
|
1582 | - * |
|
1583 | - * @param array $post_content |
|
1584 | - * @return string $post_content ( json encoded array ) |
|
1585 | - */ |
|
1586 | - public static function prepare_and_encode( $post_content ) { |
|
1587 | - //Loop through array to strip slashes and add only the needed ones |
|
1578 | + /** |
|
1579 | + * Prepare and json_encode post content |
|
1580 | + * |
|
1581 | + * @since 2.0 |
|
1582 | + * |
|
1583 | + * @param array $post_content |
|
1584 | + * @return string $post_content ( json encoded array ) |
|
1585 | + */ |
|
1586 | + public static function prepare_and_encode( $post_content ) { |
|
1587 | + //Loop through array to strip slashes and add only the needed ones |
|
1588 | 1588 | foreach ( $post_content as $key => $val ) { |
1589 | 1589 | // Replace problematic characters (like ") |
1590 | 1590 | $val = str_replace( '"', '"', $val ); |
1591 | 1591 | |
1592 | 1592 | self::prepare_action_slashes( $val, $key, $post_content ); |
1593 | - unset( $key, $val ); |
|
1594 | - } |
|
1593 | + unset( $key, $val ); |
|
1594 | + } |
|
1595 | 1595 | |
1596 | - // json_encode the array |
|
1597 | - $post_content = json_encode( $post_content ); |
|
1596 | + // json_encode the array |
|
1597 | + $post_content = json_encode( $post_content ); |
|
1598 | 1598 | |
1599 | - // add extra slashes for \r\n since WP strips them |
|
1599 | + // add extra slashes for \r\n since WP strips them |
|
1600 | 1600 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
1601 | 1601 | |
1602 | - // allow for " |
|
1603 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
1602 | + // allow for " |
|
1603 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
1604 | 1604 | |
1605 | - return $post_content; |
|
1606 | - } |
|
1605 | + return $post_content; |
|
1606 | + } |
|
1607 | 1607 | |
1608 | 1608 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1609 | 1609 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1671,64 +1671,64 @@ discard block |
||
1671 | 1671 | } |
1672 | 1672 | |
1673 | 1673 | public static function maybe_json_decode( $string ) { |
1674 | - if ( is_array($string) ) { |
|
1675 | - return $string; |
|
1676 | - } |
|
1674 | + if ( is_array($string) ) { |
|
1675 | + return $string; |
|
1676 | + } |
|
1677 | 1677 | |
1678 | - $new_string = json_decode($string, true); |
|
1679 | - if ( function_exists('json_last_error') ) { |
|
1678 | + $new_string = json_decode($string, true); |
|
1679 | + if ( function_exists('json_last_error') ) { |
|
1680 | 1680 | // php 5.3+ |
1681 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1682 | - $string = $new_string; |
|
1683 | - } |
|
1684 | - } else if ( isset($new_string) ) { |
|
1681 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1682 | + $string = $new_string; |
|
1683 | + } |
|
1684 | + } else if ( isset($new_string) ) { |
|
1685 | 1685 | // php < 5.3 fallback |
1686 | - $string = $new_string; |
|
1687 | - } |
|
1688 | - return $string; |
|
1689 | - } |
|
1690 | - |
|
1691 | - /** |
|
1692 | - * @since 1.07.10 |
|
1693 | - * |
|
1694 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
1695 | - * echo The javascript to open and highlight the Formidable menu |
|
1696 | - */ |
|
1686 | + $string = $new_string; |
|
1687 | + } |
|
1688 | + return $string; |
|
1689 | + } |
|
1690 | + |
|
1691 | + /** |
|
1692 | + * @since 1.07.10 |
|
1693 | + * |
|
1694 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
1695 | + * echo The javascript to open and highlight the Formidable menu |
|
1696 | + */ |
|
1697 | 1697 | public static function maybe_highlight_menu( $post_type ) { |
1698 | - global $post; |
|
1698 | + global $post; |
|
1699 | 1699 | |
1700 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1701 | - return; |
|
1702 | - } |
|
1700 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1701 | + return; |
|
1702 | + } |
|
1703 | 1703 | |
1704 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1705 | - return; |
|
1706 | - } |
|
1704 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
1705 | + return; |
|
1706 | + } |
|
1707 | 1707 | |
1708 | - self::load_admin_wide_js(); |
|
1709 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1710 | - } |
|
1708 | + self::load_admin_wide_js(); |
|
1709 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1710 | + } |
|
1711 | 1711 | |
1712 | - /** |
|
1713 | - * Load the JS file on non-Formidable pages in the admin area |
|
1714 | - * @since 2.0 |
|
1715 | - */ |
|
1712 | + /** |
|
1713 | + * Load the JS file on non-Formidable pages in the admin area |
|
1714 | + * @since 2.0 |
|
1715 | + */ |
|
1716 | 1716 | public static function load_admin_wide_js( $load = true ) { |
1717 | - $version = FrmAppHelper::plugin_version(); |
|
1717 | + $version = FrmAppHelper::plugin_version(); |
|
1718 | 1718 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
1719 | 1719 | |
1720 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1720 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1721 | 1721 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
1722 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1722 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1723 | 1723 | 'url' => FrmAppHelper::plugin_url(), |
1724 | 1724 | 'loading' => __( 'Loading…' ), |
1725 | 1725 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
1726 | - ) ); |
|
1726 | + ) ); |
|
1727 | 1727 | |
1728 | 1728 | if ( $load ) { |
1729 | 1729 | wp_enqueue_script( 'formidable_admin_global' ); |
1730 | 1730 | } |
1731 | - } |
|
1731 | + } |
|
1732 | 1732 | |
1733 | 1733 | /** |
1734 | 1734 | * @since 2.0.9 |
@@ -1737,9 +1737,9 @@ discard block |
||
1737 | 1737 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
1738 | 1738 | } |
1739 | 1739 | |
1740 | - /** |
|
1741 | - * @param string $location |
|
1742 | - */ |
|
1740 | + /** |
|
1741 | + * @param string $location |
|
1742 | + */ |
|
1743 | 1743 | public static function localize_script( $location ) { |
1744 | 1744 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
1745 | 1745 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1795,81 +1795,81 @@ discard block |
||
1795 | 1795 | } |
1796 | 1796 | } |
1797 | 1797 | |
1798 | - /** |
|
1798 | + /** |
|
1799 | 1799 | * echo the message on the plugins listing page |
1800 | - * @since 1.07.10 |
|
1801 | - * |
|
1802 | - * @param float $min_version The version the add-on requires |
|
1803 | - */ |
|
1800 | + * @since 1.07.10 |
|
1801 | + * |
|
1802 | + * @param float $min_version The version the add-on requires |
|
1803 | + */ |
|
1804 | 1804 | public static function min_version_notice( $min_version ) { |
1805 | - $frm_version = self::plugin_version(); |
|
1805 | + $frm_version = self::plugin_version(); |
|
1806 | 1806 | |
1807 | - // check if Formidable meets minimum requirements |
|
1808 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1809 | - return; |
|
1810 | - } |
|
1807 | + // check if Formidable meets minimum requirements |
|
1808 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1809 | + return; |
|
1810 | + } |
|
1811 | 1811 | |
1812 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1812 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1813 | 1813 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
1814 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1815 | - '</div></td></tr>'; |
|
1816 | - } |
|
1817 | - |
|
1818 | - public static function locales( $type = 'date' ) { |
|
1819 | - $locales = array( |
|
1820 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1821 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1822 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1823 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1824 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1825 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1826 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1827 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1828 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1829 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1830 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1831 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1832 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1833 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1834 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1835 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1836 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1837 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1838 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1839 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1840 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1841 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1842 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1843 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1844 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1845 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1846 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1847 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1848 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1849 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1850 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1851 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1852 | - ); |
|
1853 | - |
|
1854 | - if ( $type == 'captcha' ) { |
|
1855 | - // remove the languages unavailable for the captcha |
|
1856 | - $unset = array( |
|
1857 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1858 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1859 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1860 | - ); |
|
1861 | - } else { |
|
1862 | - // remove the languages unavailable for the datepicker |
|
1863 | - $unset = array( |
|
1864 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1865 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1866 | - 'es-419', 'tr', |
|
1867 | - ); |
|
1868 | - } |
|
1869 | - |
|
1870 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1871 | - $locales = apply_filters('frm_locales', $locales); |
|
1872 | - |
|
1873 | - return $locales; |
|
1874 | - } |
|
1814 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1815 | + '</div></td></tr>'; |
|
1816 | + } |
|
1817 | + |
|
1818 | + public static function locales( $type = 'date' ) { |
|
1819 | + $locales = array( |
|
1820 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1821 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1822 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1823 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1824 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1825 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1826 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1827 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1828 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1829 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1830 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1831 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1832 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1833 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1834 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1835 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1836 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1837 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1838 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1839 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1840 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1841 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1842 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1843 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1844 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1845 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1846 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1847 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1848 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1849 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1850 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1851 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1852 | + ); |
|
1853 | + |
|
1854 | + if ( $type == 'captcha' ) { |
|
1855 | + // remove the languages unavailable for the captcha |
|
1856 | + $unset = array( |
|
1857 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1858 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1859 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1860 | + ); |
|
1861 | + } else { |
|
1862 | + // remove the languages unavailable for the datepicker |
|
1863 | + $unset = array( |
|
1864 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1865 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1866 | + 'es-419', 'tr', |
|
1867 | + ); |
|
1868 | + } |
|
1869 | + |
|
1870 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
1871 | + $locales = apply_filters('frm_locales', $locales); |
|
1872 | + |
|
1873 | + return $locales; |
|
1874 | + } |
|
1875 | 1875 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function plugin_folder() { |
26 | - return basename(self::plugin_path()); |
|
26 | + return basename( self::plugin_path() ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function plugin_path() { |
30 | - return dirname(dirname(dirname(__FILE__))); |
|
30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public static function plugin_url() { |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | public static function site_name() { |
57 | - return get_option('blogname'); |
|
57 | + return get_option( 'blogname' ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function make_affiliate_url( $url ) { |
61 | 61 | $affiliate_id = self::get_affiliate(); |
62 | 62 | if ( ! empty( $affiliate_id ) ) { |
63 | 63 | $url = str_replace( array( 'http://', 'https://' ), '', $url ); |
64 | - $url = 'http://www.shareasale.com/r.cfm?u='. absint( $affiliate_id ) .'&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url ); |
|
64 | + $url = 'http://www.shareasale.com/r.cfm?u=' . absint( $affiliate_id ) . '&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url ); |
|
65 | 65 | } |
66 | 66 | return $url; |
67 | 67 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function get_settings() { |
82 | 82 | global $frm_settings; |
83 | - if ( empty($frm_settings) ) { |
|
83 | + if ( empty( $frm_settings ) ) { |
|
84 | 84 | $frm_settings = new FrmSettings(); |
85 | 85 | } |
86 | 86 | return $frm_settings; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | public static function pro_is_installed() { |
112 | - return apply_filters('frm_pro_installed', false); |
|
112 | + return apply_filters( 'frm_pro_installed', false ); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return boolean |
154 | 154 | */ |
155 | 155 | public static function doing_ajax() { |
156 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
156 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return boolean |
174 | 174 | */ |
175 | 175 | public static function is_admin() { |
176 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
176 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @return string |
201 | 201 | */ |
202 | 202 | public static function get_server_value( $value ) { |
203 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
203 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
216 | 216 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
217 | 217 | ) as $key ) { |
218 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
218 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
219 | 219 | continue; |
220 | 220 | } |
221 | 221 | |
222 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
223 | - $ip = trim($ip); // just to be safe |
|
222 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
223 | + $ip = trim( $ip ); // just to be safe |
|
224 | 224 | |
225 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
225 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
226 | 226 | return $ip; |
227 | 227 | } |
228 | 228 | } |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
235 | - if ( strpos($param, '[') ) { |
|
236 | - $params = explode('[', $param); |
|
235 | + if ( strpos( $param, '[' ) ) { |
|
236 | + $params = explode( '[', $param ); |
|
237 | 237 | $param = $params[0]; |
238 | 238 | } |
239 | 239 | |
240 | 240 | if ( $src == 'get' ) { |
241 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
242 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
243 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
241 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
242 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
243 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) ); |
|
244 | 244 | } |
245 | 245 | self::sanitize_value( $sanitize, $value ); |
246 | 246 | } else { |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | |
250 | 250 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
251 | 251 | foreach ( $params as $k => $p ) { |
252 | - if ( ! $k || ! is_array($value) ) { |
|
252 | + if ( ! $k || ! is_array( $value ) ) { |
|
253 | 253 | continue; |
254 | 254 | } |
255 | 255 | |
256 | - $p = trim($p, ']'); |
|
257 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
256 | + $p = trim( $p, ']' ); |
|
257 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
@@ -293,16 +293,16 @@ discard block |
||
293 | 293 | |
294 | 294 | $value = $args['default']; |
295 | 295 | if ( $args['type'] == 'get' ) { |
296 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
297 | - $value = $_GET[ $args['param'] ]; |
|
296 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
297 | + $value = $_GET[$args['param']]; |
|
298 | 298 | } |
299 | 299 | } else if ( $args['type'] == 'post' ) { |
300 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
301 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
300 | + if ( isset( $_POST[$args['param']] ) ) { |
|
301 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
302 | 302 | } |
303 | 303 | } else { |
304 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
305 | - $value = $_REQUEST[ $args['param'] ]; |
|
304 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
305 | + $value = $_REQUEST[$args['param']]; |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | if ( is_array( $value ) ) { |
331 | 331 | $temp_values = $value; |
332 | 332 | foreach ( $temp_values as $k => $v ) { |
333 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
333 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
334 | 334 | } |
335 | 335 | } else { |
336 | 336 | $value = call_user_func( $sanitize, $value ); |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | public static function sanitize_request( $sanitize_method, &$values ) { |
342 | 342 | $temp_values = $values; |
343 | 343 | foreach ( $temp_values as $k => $val ) { |
344 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
345 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
344 | + if ( isset( $sanitize_method[$k] ) ) { |
|
345 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | public static function sanitize_array( &$values ) { |
351 | 351 | $temp_values = $values; |
352 | 352 | foreach ( $temp_values as $k => $val ) { |
353 | - $values[ $k ] = wp_kses_post( $val ); |
|
353 | + $values[$k] = wp_kses_post( $val ); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | $allowed_html = array(); |
375 | 375 | foreach ( $allowed as $a ) { |
376 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
376 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | $allowed_html = apply_filters( 'frm_striphtml_allowed_tags', $allowed_html ); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * @since 2.0 |
387 | 387 | */ |
388 | 388 | public static function remove_get_action() { |
389 | - if ( ! isset($_GET) ) { |
|
389 | + if ( ! isset( $_GET ) ) { |
|
390 | 390 | return; |
391 | 391 | } |
392 | 392 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | global $wp_query; |
411 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
412 | - $value = $wp_query->query_vars[ $param ]; |
|
411 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
412 | + $value = $wp_query->query_vars[$param]; |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | return $value; |
@@ -438,19 +438,19 @@ discard block |
||
438 | 438 | * @return mixed $results The cache or query results |
439 | 439 | */ |
440 | 440 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
441 | - $results = wp_cache_get($cache_key, $group); |
|
442 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
441 | + $results = wp_cache_get( $cache_key, $group ); |
|
442 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
443 | 443 | return $results; |
444 | 444 | } |
445 | 445 | |
446 | 446 | if ( 'get_posts' == $type ) { |
447 | - $results = get_posts($query); |
|
447 | + $results = get_posts( $query ); |
|
448 | 448 | } else if ( 'get_associative_results' == $type ) { |
449 | 449 | global $wpdb; |
450 | 450 | $results = $wpdb->get_results( $query, OBJECT_K ); |
451 | 451 | } else { |
452 | 452 | global $wpdb; |
453 | - $results = $wpdb->{$type}($query); |
|
453 | + $results = $wpdb->{$type}( $query ); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | self::set_cache( $cache_key, $results, $group, $time ); |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | public static function add_key_to_group_cache( $key, $group ) { |
473 | 473 | $cached = self::get_group_cached_keys( $group ); |
474 | - $cached[ $key ] = $key; |
|
474 | + $cached[$key] = $key; |
|
475 | 475 | wp_cache_set( 'cached_keys', $cached, $group, 300 ); |
476 | 476 | } |
477 | 477 | |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | } |
499 | 499 | |
500 | 500 | // then check the transient |
501 | - $results = get_transient($cache_key); |
|
501 | + $results = get_transient( $cache_key ); |
|
502 | 502 | if ( $results ) { |
503 | - wp_cache_set($cache_key, $results); |
|
503 | + wp_cache_set( $cache_key, $results ); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | return $results; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @param string $cache_key |
512 | 512 | */ |
513 | 513 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
514 | - delete_transient($cache_key); |
|
514 | + delete_transient( $cache_key ); |
|
515 | 515 | wp_cache_delete( $cache_key, $group ); |
516 | 516 | } |
517 | 517 | |
@@ -555,17 +555,17 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | public static function get_pages() { |
558 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
558 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
562 | 562 | $pages = self::get_pages(); |
563 | 563 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
564 | 564 | ?> |
565 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
565 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
566 | 566 | <option value=""> </option> |
567 | 567 | <?php foreach ( $pages as $page ) { ?> |
568 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
568 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
569 | 569 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
570 | 570 | </option> |
571 | 571 | <?php } ?> |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | } |
575 | 575 | |
576 | 576 | public static function post_edit_link( $post_id ) { |
577 | - $post = get_post($post_id); |
|
577 | + $post = get_post( $post_id ); |
|
578 | 578 | if ( $post ) { |
579 | 579 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
580 | 580 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -584,17 +584,17 @@ discard block |
||
584 | 584 | |
585 | 585 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
586 | 586 | ?> |
587 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
587 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
588 | 588 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
589 | 589 | ?> class="frm_multiselect"> |
590 | - <?php self::roles_options($capability); ?> |
|
590 | + <?php self::roles_options( $capability ); ?> |
|
591 | 591 | </select> |
592 | 592 | <?php |
593 | 593 | } |
594 | 594 | |
595 | 595 | public static function roles_options( $capability ) { |
596 | 596 | global $frm_vars; |
597 | - if ( isset($frm_vars['editable_roles']) ) { |
|
597 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
598 | 598 | $editable_roles = $frm_vars['editable_roles']; |
599 | 599 | } else { |
600 | 600 | $editable_roles = get_editable_roles(); |
@@ -602,10 +602,10 @@ discard block |
||
602 | 602 | } |
603 | 603 | |
604 | 604 | foreach ( $editable_roles as $role => $details ) { |
605 | - $name = translate_user_role($details['name'] ); ?> |
|
606 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
605 | + $name = translate_user_role( $details['name'] ); ?> |
|
606 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
607 | 607 | <?php |
608 | - unset($role, $details); |
|
608 | + unset( $role, $details ); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | public static function maybe_add_permissions() { |
662 | 662 | self::force_capability( 'frm_view_entries' ); |
663 | 663 | |
664 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
664 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
665 | 665 | return; |
666 | 666 | } |
667 | 667 | |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | $frm_roles = self::frm_capabilities(); |
671 | 671 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
672 | 672 | $user->add_cap( $frm_role ); |
673 | - unset($frm_role, $frm_role_description); |
|
673 | + unset( $frm_role, $frm_role_description ); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
@@ -695,12 +695,12 @@ discard block |
||
695 | 695 | * @param string $permission |
696 | 696 | */ |
697 | 697 | public static function permission_check( $permission, $show_message = 'show' ) { |
698 | - $permission_error = self::permission_nonce_error($permission); |
|
698 | + $permission_error = self::permission_nonce_error( $permission ); |
|
699 | 699 | if ( $permission_error !== false ) { |
700 | 700 | if ( 'hide' == $show_message ) { |
701 | 701 | $permission_error = ''; |
702 | 702 | } |
703 | - wp_die($permission_error); |
|
703 | + wp_die( $permission_error ); |
|
704 | 704 | } |
705 | 705 | } |
706 | 706 | |
@@ -717,11 +717,11 @@ discard block |
||
717 | 717 | } |
718 | 718 | |
719 | 719 | $error = false; |
720 | - if ( empty($nonce_name) ) { |
|
720 | + if ( empty( $nonce_name ) ) { |
|
721 | 721 | return $error; |
722 | 722 | } |
723 | 723 | |
724 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
724 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
725 | 725 | $frm_settings = self::get_settings(); |
726 | 726 | $error = $frm_settings->admin_permission; |
727 | 727 | } |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | } else { |
802 | 802 | foreach ( $value as $k => $v ) { |
803 | 803 | if ( ! is_array( $v ) ) { |
804 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
804 | + $value[$k] = call_user_func( $original_function, $v ); |
|
805 | 805 | } |
806 | 806 | } |
807 | 807 | } |
@@ -822,11 +822,11 @@ discard block |
||
822 | 822 | public static function array_flatten( $array, $keys = 'keep' ) { |
823 | 823 | $return = array(); |
824 | 824 | foreach ( $array as $key => $value ) { |
825 | - if ( is_array($value) ) { |
|
825 | + if ( is_array( $value ) ) { |
|
826 | 826 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
827 | 827 | } else { |
828 | 828 | if ( $keys == 'keep' ) { |
829 | - $return[ $key ] = $value; |
|
829 | + $return[$key] = $value; |
|
830 | 830 | } else { |
831 | 831 | $return[] = $value; |
832 | 832 | } |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | * @since 2.0 |
850 | 850 | */ |
851 | 851 | public static function use_wpautop( $content ) { |
852 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
853 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
852 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
853 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
854 | 854 | } |
855 | 855 | return $content; |
856 | 856 | } |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | */ |
870 | 870 | public static function jquery_ui_base_url() { |
871 | 871 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
872 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
872 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
873 | 873 | return $url; |
874 | 874 | } |
875 | 875 | |
@@ -883,11 +883,11 @@ discard block |
||
883 | 883 | } |
884 | 884 | |
885 | 885 | $ver = $default; |
886 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
886 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
887 | 887 | return $ver; |
888 | 888 | } |
889 | 889 | |
890 | - $query = $wp_scripts->registered[ $handle ]; |
|
890 | + $query = $wp_scripts->registered[$handle]; |
|
891 | 891 | if ( is_object( $query ) && ! empty( $query->ver ) ) { |
892 | 892 | $ver = $query->ver; |
893 | 893 | } |
@@ -900,36 +900,36 @@ discard block |
||
900 | 900 | } |
901 | 901 | |
902 | 902 | public static function get_user_id_param( $user_id ) { |
903 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
903 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
904 | 904 | return $user_id; |
905 | 905 | } |
906 | 906 | |
907 | 907 | if ( $user_id == 'current' ) { |
908 | 908 | $user_id = get_current_user_id(); |
909 | 909 | } else { |
910 | - if ( is_email($user_id) ) { |
|
911 | - $user = get_user_by('email', $user_id); |
|
910 | + if ( is_email( $user_id ) ) { |
|
911 | + $user = get_user_by( 'email', $user_id ); |
|
912 | 912 | } else { |
913 | - $user = get_user_by('login', $user_id); |
|
913 | + $user = get_user_by( 'login', $user_id ); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | if ( $user ) { |
917 | 917 | $user_id = $user->ID; |
918 | 918 | } |
919 | - unset($user); |
|
919 | + unset( $user ); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | return $user_id; |
923 | 923 | } |
924 | 924 | |
925 | 925 | public static function get_file_contents( $filename, $atts = array() ) { |
926 | - if ( ! is_file($filename) ) { |
|
926 | + if ( ! is_file( $filename ) ) { |
|
927 | 927 | return false; |
928 | 928 | } |
929 | 929 | |
930 | - extract($atts); |
|
930 | + extract( $atts ); |
|
931 | 931 | ob_start(); |
932 | - include($filename); |
|
932 | + include( $filename ); |
|
933 | 933 | $contents = ob_get_contents(); |
934 | 934 | ob_end_clean(); |
935 | 935 | return $contents; |
@@ -945,27 +945,27 @@ discard block |
||
945 | 945 | $key = ''; |
946 | 946 | |
947 | 947 | if ( ! empty( $name ) ) { |
948 | - $key = sanitize_key($name); |
|
948 | + $key = sanitize_key( $name ); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | if ( empty( $key ) ) { |
952 | - $max_slug_value = pow(36, $num_chars); |
|
952 | + $max_slug_value = pow( 36, $num_chars ); |
|
953 | 953 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
954 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
954 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
955 | 955 | } |
956 | 956 | |
957 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
957 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
958 | 958 | $key = $key . 'a'; |
959 | 959 | } |
960 | 960 | |
961 | 961 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
962 | 962 | |
963 | - if ( $key_check || is_numeric($key_check) ) { |
|
963 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
964 | 964 | $suffix = 2; |
965 | 965 | do { |
966 | 966 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
967 | 967 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
968 | - $suffix++; |
|
968 | + $suffix ++; |
|
969 | 969 | } while ( $key_check || is_numeric( $key_check ) ); |
970 | 970 | $key = $alt_post_name; |
971 | 971 | } |
@@ -982,32 +982,32 @@ discard block |
||
982 | 982 | return false; |
983 | 983 | } |
984 | 984 | |
985 | - if ( empty($post_values) ) { |
|
986 | - $post_values = stripslashes_deep($_POST); |
|
985 | + if ( empty( $post_values ) ) { |
|
986 | + $post_values = stripslashes_deep( $_POST ); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | $values = array( 'id' => $record->id, 'fields' => array() ); |
990 | 990 | |
991 | 991 | foreach ( array( 'name', 'description' ) as $var ) { |
992 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
993 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
994 | - unset($var, $default_val); |
|
992 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
993 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
994 | + unset( $var, $default_val ); |
|
995 | 995 | } |
996 | 996 | |
997 | - $values['description'] = self::use_wpautop($values['description']); |
|
997 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
998 | 998 | $frm_settings = self::get_settings(); |
999 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
999 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
1000 | 1000 | |
1001 | 1001 | foreach ( (array) $fields as $field ) { |
1002 | 1002 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
1003 | 1003 | if ( ! $is_form_builder ) { |
1004 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
1004 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
1005 | 1005 | } |
1006 | 1006 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
1007 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
1007 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
1010 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
1011 | 1011 | |
1012 | 1012 | if ( $table == 'entries' ) { |
1013 | 1013 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1024,8 +1024,8 @@ discard block |
||
1024 | 1024 | if ( $args['default'] ) { |
1025 | 1025 | $meta_value = $field->default_value; |
1026 | 1026 | } else { |
1027 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1028 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1027 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
1028 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
1029 | 1029 | $field->field_options['custom_field'] = ''; |
1030 | 1030 | } |
1031 | 1031 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -1034,8 +1034,8 @@ discard block |
||
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
1038 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1037 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
1038 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
1039 | 1039 | |
1040 | 1040 | $field_array = array( |
1041 | 1041 | 'id' => $field->id, |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | 'default_value' => $field->default_value, |
1044 | 1044 | 'name' => $field->name, |
1045 | 1045 | 'description' => $field->description, |
1046 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1046 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
1047 | 1047 | 'options' => $field->options, |
1048 | 1048 | 'required' => $field->required, |
1049 | 1049 | 'field_key' => $field->field_key, |
@@ -1053,40 +1053,40 @@ discard block |
||
1053 | 1053 | ); |
1054 | 1054 | |
1055 | 1055 | $args['field_type'] = $field_type; |
1056 | - self::fill_field_opts($field, $field_array, $args); |
|
1056 | + self::fill_field_opts( $field, $field_array, $args ); |
|
1057 | 1057 | // Track the original field's type |
1058 | 1058 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
1059 | 1059 | |
1060 | 1060 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
1061 | 1061 | |
1062 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1062 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
1063 | 1063 | $field_array['unique_msg'] = ''; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | $field_array = array_merge( $field->field_options, $field_array ); |
1067 | 1067 | |
1068 | - $values['fields'][ $field->id ] = $field_array; |
|
1068 | + $values['fields'][$field->id] = $field_array; |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1072 | 1072 | $post_values = $args['post_values']; |
1073 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1073 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
1074 | 1074 | |
1075 | 1075 | foreach ( $opt_defaults as $opt => $default_opt ) { |
1076 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1077 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1078 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1079 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1076 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
1077 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
1078 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
1079 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
1080 | 1080 | if ( $args['field_type'] == 'captcha' ) { |
1081 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1081 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
1082 | 1082 | } else { |
1083 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1083 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | if ( $field_array['custom_html'] == '' ) { |
1089 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1089 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | |
@@ -1105,18 +1105,18 @@ discard block |
||
1105 | 1105 | return; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1108 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
1109 | 1109 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1110 | 1110 | |
1111 | - if ( ! is_array($form->options) ) { |
|
1111 | + if ( ! is_array( $form->options ) ) { |
|
1112 | 1112 | return; |
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | foreach ( $form->options as $opt => $value ) { |
1116 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1116 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | - self::fill_form_defaults($post_values, $values); |
|
1119 | + self::fill_form_defaults( $post_values, $values ); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | /** |
@@ -1126,11 +1126,11 @@ discard block |
||
1126 | 1126 | $form_defaults = FrmFormsHelper::get_default_opts(); |
1127 | 1127 | |
1128 | 1128 | foreach ( $form_defaults as $opt => $default ) { |
1129 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1130 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
1129 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
1130 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | - unset($opt, $defaut); |
|
1133 | + unset( $opt, $defaut ); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | if ( ! isset( $values['custom_style'] ) ) { |
@@ -1138,10 +1138,10 @@ discard block |
||
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1141 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
1142 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1141 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
1142 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
1143 | 1143 | } |
1144 | - unset($h); |
|
1144 | + unset( $h ); |
|
1145 | 1145 | } |
1146 | 1146 | } |
1147 | 1147 | |
@@ -1172,9 +1172,9 @@ discard block |
||
1172 | 1172 | } |
1173 | 1173 | ?> |
1174 | 1174 | <li> |
1175 | - <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
1176 | - <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
|
1177 | - <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
|
1175 | + <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
1176 | + <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a> |
|
1177 | + <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a> |
|
1178 | 1178 | </li> |
1179 | 1179 | <?php |
1180 | 1180 | } |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | return ''; |
1193 | 1193 | } else if ( $length <= 10 ) { |
1194 | 1194 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1195 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1195 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | $sub = ''; |
@@ -1201,23 +1201,23 @@ discard block |
||
1201 | 1201 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1202 | 1202 | |
1203 | 1203 | foreach ( $words as $word ) { |
1204 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1204 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
1205 | 1205 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1206 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1206 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
1207 | 1207 | break; |
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | $sub .= $part; |
1211 | 1211 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1212 | 1212 | |
1213 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1213 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
1214 | 1214 | break; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - unset($total_len, $word); |
|
1217 | + unset( $total_len, $word ); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1220 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | public static function mb_function( $function_names, $args ) { |
@@ -1230,17 +1230,17 @@ discard block |
||
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1233 | - if ( empty($date) ) { |
|
1233 | + if ( empty( $date ) ) { |
|
1234 | 1234 | return $date; |
1235 | 1235 | } |
1236 | 1236 | |
1237 | - if ( empty($date_format) ) { |
|
1238 | - $date_format = get_option('date_format'); |
|
1237 | + if ( empty( $date_format ) ) { |
|
1238 | + $date_format = get_option( 'date_format' ); |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1241 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
1242 | 1242 | $frmpro_settings = new FrmProSettings(); |
1243 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1243 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | 1246 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | |
1256 | 1256 | private static function add_time_to_date( $time_format, $date ) { |
1257 | 1257 | if ( empty( $time_format ) ) { |
1258 | - $time_format = get_option('time_format'); |
|
1258 | + $time_format = get_option( 'time_format' ); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | $trimmed_format = trim( $time_format ); |
@@ -1301,10 +1301,10 @@ discard block |
||
1301 | 1301 | $time_strings = self::get_time_strings(); |
1302 | 1302 | |
1303 | 1303 | foreach ( $time_strings as $k => $v ) { |
1304 | - if ( $diff[ $k ] ) { |
|
1305 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
1304 | + if ( $diff[$k] ) { |
|
1305 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
1306 | 1306 | } else { |
1307 | - unset( $time_strings[ $k ] ); |
|
1307 | + unset( $time_strings[$k] ); |
|
1308 | 1308 | } |
1309 | 1309 | } |
1310 | 1310 | |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | */ |
1344 | 1344 | public static function esc_like( $term ) { |
1345 | 1345 | global $wpdb; |
1346 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1346 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
1347 | 1347 | // WP 4.0 |
1348 | 1348 | $term = $wpdb->esc_like( $term ); |
1349 | 1349 | } else { |
@@ -1357,17 +1357,17 @@ discard block |
||
1357 | 1357 | * @param string $order_query |
1358 | 1358 | */ |
1359 | 1359 | public static function esc_order( $order_query ) { |
1360 | - if ( empty($order_query) ) { |
|
1360 | + if ( empty( $order_query ) ) { |
|
1361 | 1361 | return ''; |
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | // remove ORDER BY before santizing |
1365 | - $order_query = strtolower($order_query); |
|
1366 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1367 | - $order_query = str_replace('order by', '', $order_query); |
|
1365 | + $order_query = strtolower( $order_query ); |
|
1366 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
1367 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | - $order_query = explode(' ', trim($order_query)); |
|
1370 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
1371 | 1371 | |
1372 | 1372 | $order_fields = array( |
1373 | 1373 | 'id', 'form_key', 'name', 'description', |
@@ -1375,13 +1375,13 @@ discard block |
||
1375 | 1375 | 'default_template', 'status', 'created_at', |
1376 | 1376 | ); |
1377 | 1377 | |
1378 | - $order = trim(trim(reset($order_query), ',')); |
|
1379 | - if ( ! in_array($order, $order_fields) ) { |
|
1378 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
1379 | + if ( ! in_array( $order, $order_fields ) ) { |
|
1380 | 1380 | return ''; |
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | $order_by = ''; |
1384 | - if ( count($order_query) > 1 ) { |
|
1384 | + if ( count( $order_query ) > 1 ) { |
|
1385 | 1385 | $order_by = end( $order_query ); |
1386 | 1386 | self::esc_order_by( $order_by ); |
1387 | 1387 | } |
@@ -1403,23 +1403,23 @@ discard block |
||
1403 | 1403 | * @param string $limit |
1404 | 1404 | */ |
1405 | 1405 | public static function esc_limit( $limit ) { |
1406 | - if ( empty($limit) ) { |
|
1406 | + if ( empty( $limit ) ) { |
|
1407 | 1407 | return ''; |
1408 | 1408 | } |
1409 | 1409 | |
1410 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1411 | - if ( is_numeric($limit) ) { |
|
1410 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
1411 | + if ( is_numeric( $limit ) ) { |
|
1412 | 1412 | return ' LIMIT ' . $limit; |
1413 | 1413 | } |
1414 | 1414 | |
1415 | - $limit = explode(',', trim($limit)); |
|
1415 | + $limit = explode( ',', trim( $limit ) ); |
|
1416 | 1416 | foreach ( $limit as $k => $l ) { |
1417 | 1417 | if ( is_numeric( $l ) ) { |
1418 | - $limit[ $k ] = $l; |
|
1418 | + $limit[$k] = $l; |
|
1419 | 1419 | } |
1420 | 1420 | } |
1421 | 1421 | |
1422 | - $limit = implode(',', $limit); |
|
1422 | + $limit = implode( ',', $limit ); |
|
1423 | 1423 | return ' LIMIT ' . $limit; |
1424 | 1424 | } |
1425 | 1425 | |
@@ -1428,12 +1428,12 @@ discard block |
||
1428 | 1428 | * @since 2.0 |
1429 | 1429 | */ |
1430 | 1430 | public static function prepare_array_values( $array, $type = '%s' ) { |
1431 | - $placeholders = array_fill(0, count($array), $type); |
|
1432 | - return implode(', ', $placeholders); |
|
1431 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
1432 | + return implode( ', ', $placeholders ); |
|
1433 | 1433 | } |
1434 | 1434 | |
1435 | 1435 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
1436 | - if ( empty($where) ) { |
|
1436 | + if ( empty( $where ) ) { |
|
1437 | 1437 | return ''; |
1438 | 1438 | } |
1439 | 1439 | |
@@ -1474,19 +1474,19 @@ discard block |
||
1474 | 1474 | public static function json_to_array( $json_vars ) { |
1475 | 1475 | $vars = array(); |
1476 | 1476 | foreach ( $json_vars as $jv ) { |
1477 | - $jv_name = explode('[', $jv['name']); |
|
1478 | - $last = count($jv_name) - 1; |
|
1477 | + $jv_name = explode( '[', $jv['name'] ); |
|
1478 | + $last = count( $jv_name ) - 1; |
|
1479 | 1479 | foreach ( $jv_name as $p => $n ) { |
1480 | - $name = trim($n, ']'); |
|
1481 | - if ( ! isset($l1) ) { |
|
1480 | + $name = trim( $n, ']' ); |
|
1481 | + if ( ! isset( $l1 ) ) { |
|
1482 | 1482 | $l1 = $name; |
1483 | 1483 | } |
1484 | 1484 | |
1485 | - if ( ! isset($l2) ) { |
|
1485 | + if ( ! isset( $l2 ) ) { |
|
1486 | 1486 | $l2 = $name; |
1487 | 1487 | } |
1488 | 1488 | |
1489 | - if ( ! isset($l3) ) { |
|
1489 | + if ( ! isset( $l3 ) ) { |
|
1490 | 1490 | $l3 = $name; |
1491 | 1491 | } |
1492 | 1492 | |
@@ -1500,24 +1500,24 @@ discard block |
||
1500 | 1500 | |
1501 | 1501 | case 1: |
1502 | 1502 | $l2 = $name; |
1503 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1503 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
1504 | 1504 | break; |
1505 | 1505 | |
1506 | 1506 | case 2: |
1507 | 1507 | $l3 = $name; |
1508 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1508 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
1509 | 1509 | break; |
1510 | 1510 | |
1511 | 1511 | case 3: |
1512 | 1512 | $l4 = $name; |
1513 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1513 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
1514 | 1514 | break; |
1515 | 1515 | } |
1516 | 1516 | |
1517 | - unset($this_val, $n); |
|
1517 | + unset( $this_val, $n ); |
|
1518 | 1518 | } |
1519 | 1519 | |
1520 | - unset($last, $jv); |
|
1520 | + unset( $last, $jv ); |
|
1521 | 1521 | } |
1522 | 1522 | |
1523 | 1523 | return $vars; |
@@ -1530,8 +1530,8 @@ discard block |
||
1530 | 1530 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
1531 | 1531 | if ( $name == '' ) { |
1532 | 1532 | $vars[] = $val; |
1533 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1534 | - $vars[ $l1 ] = $val; |
|
1533 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
1534 | + $vars[$l1] = $val; |
|
1535 | 1535 | } |
1536 | 1536 | } |
1537 | 1537 | |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
1547 | 1547 | ); |
1548 | 1548 | |
1549 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1549 | + if ( ! isset( $tooltips[$name] ) ) { |
|
1550 | 1550 | return; |
1551 | 1551 | } |
1552 | 1552 | |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | echo ' class="frm_help"'; |
1557 | 1557 | } |
1558 | 1558 | |
1559 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
1559 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
1560 | 1560 | |
1561 | 1561 | if ( 'open' != $class ) { |
1562 | 1562 | echo '"'; |
@@ -1608,13 +1608,13 @@ discard block |
||
1608 | 1608 | } |
1609 | 1609 | |
1610 | 1610 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1611 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
1611 | + if ( ! isset( $post_content[$key] ) ) { |
|
1612 | 1612 | return; |
1613 | 1613 | } |
1614 | 1614 | |
1615 | 1615 | if ( is_array( $val ) ) { |
1616 | 1616 | foreach ( $val as $k1 => $v1 ) { |
1617 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
1617 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
1618 | 1618 | unset( $k1, $v1 ); |
1619 | 1619 | } |
1620 | 1620 | } else { |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | $val = stripslashes( $val ); |
1623 | 1623 | |
1624 | 1624 | // Add backslashes before double quotes and forward slashes only |
1625 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
1625 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
1626 | 1626 | } |
1627 | 1627 | } |
1628 | 1628 | |
@@ -1639,7 +1639,7 @@ discard block |
||
1639 | 1639 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
1640 | 1640 | |
1641 | 1641 | if ( empty( $settings['ID'] ) ) { |
1642 | - unset( $settings['ID']); |
|
1642 | + unset( $settings['ID'] ); |
|
1643 | 1643 | } |
1644 | 1644 | |
1645 | 1645 | // delete all caches for this group |
@@ -1673,17 +1673,17 @@ discard block |
||
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | public static function maybe_json_decode( $string ) { |
1676 | - if ( is_array($string) ) { |
|
1676 | + if ( is_array( $string ) ) { |
|
1677 | 1677 | return $string; |
1678 | 1678 | } |
1679 | 1679 | |
1680 | - $new_string = json_decode($string, true); |
|
1681 | - if ( function_exists('json_last_error') ) { |
|
1680 | + $new_string = json_decode( $string, true ); |
|
1681 | + if ( function_exists( 'json_last_error' ) ) { |
|
1682 | 1682 | // php 5.3+ |
1683 | 1683 | if ( json_last_error() == JSON_ERROR_NONE ) { |
1684 | 1684 | $string = $new_string; |
1685 | 1685 | } |
1686 | - } else if ( isset($new_string) ) { |
|
1686 | + } else if ( isset( $new_string ) ) { |
|
1687 | 1687 | // php < 5.3 fallback |
1688 | 1688 | $string = $new_string; |
1689 | 1689 | } |
@@ -1699,11 +1699,11 @@ discard block |
||
1699 | 1699 | public static function maybe_highlight_menu( $post_type ) { |
1700 | 1700 | global $post; |
1701 | 1701 | |
1702 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1702 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
1703 | 1703 | return; |
1704 | 1704 | } |
1705 | 1705 | |
1706 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1706 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
1707 | 1707 | return; |
1708 | 1708 | } |
1709 | 1709 | |
@@ -1807,11 +1807,11 @@ discard block |
||
1807 | 1807 | $frm_version = self::plugin_version(); |
1808 | 1808 | |
1809 | 1809 | // check if Formidable meets minimum requirements |
1810 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1810 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
1811 | 1811 | return; |
1812 | 1812 | } |
1813 | 1813 | |
1814 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1814 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
1815 | 1815 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
1816 | 1816 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
1817 | 1817 | '</div></td></tr>'; |
@@ -1819,38 +1819,38 @@ discard block |
||
1819 | 1819 | |
1820 | 1820 | public static function locales( $type = 'date' ) { |
1821 | 1821 | $locales = array( |
1822 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1823 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1824 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1822 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1823 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1824 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1825 | 1825 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
1826 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1827 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1826 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1827 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1828 | 1828 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
1829 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1830 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1829 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1830 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1831 | 1831 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
1832 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1832 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1833 | 1833 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
1834 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1834 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1835 | 1835 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
1836 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1836 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1837 | 1837 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
1838 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1839 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1840 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1841 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1842 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1838 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1839 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1840 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1841 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1842 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1843 | 1843 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
1844 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1844 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1845 | 1845 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
1846 | 1846 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
1847 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1847 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1848 | 1848 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
1849 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1849 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1850 | 1850 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
1851 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1852 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1853 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1851 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1852 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1853 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1854 | 1854 | ); |
1855 | 1855 | |
1856 | 1856 | if ( $type == 'captcha' ) { |
@@ -1869,8 +1869,8 @@ discard block |
||
1869 | 1869 | ); |
1870 | 1870 | } |
1871 | 1871 | |
1872 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1873 | - $locales = apply_filters('frm_locales', $locales); |
|
1872 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
1873 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
1874 | 1874 | |
1875 | 1875 | return $locales; |
1876 | 1876 | } |
@@ -5,59 +5,59 @@ discard block |
||
5 | 5 | |
6 | 6 | class FrmEntriesHelper { |
7 | 7 | |
8 | - public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
8 | + public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
9 | 9 | $values = array( 'name' => '', 'description' => '', 'item_key' => '' ); |
10 | 10 | |
11 | - $values['fields'] = array(); |
|
12 | - if ( empty($fields) ) { |
|
13 | - return apply_filters('frm_setup_new_entry', $values); |
|
14 | - } |
|
11 | + $values['fields'] = array(); |
|
12 | + if ( empty($fields) ) { |
|
13 | + return apply_filters('frm_setup_new_entry', $values); |
|
14 | + } |
|
15 | 15 | |
16 | - foreach ( (array) $fields as $field ) { |
|
16 | + foreach ( (array) $fields as $field ) { |
|
17 | 17 | self::prepare_field_default_value( $field ); |
18 | - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
19 | - |
|
20 | - $field_array = array( |
|
21 | - 'id' => $field->id, |
|
22 | - 'value' => $new_value, |
|
23 | - 'default_value' => $field->default_value, |
|
24 | - 'name' => $field->name, |
|
25 | - 'description' => $field->description, |
|
26 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
27 | - 'options' => $field->options, |
|
28 | - 'required' => $field->required, |
|
29 | - 'field_key' => $field->field_key, |
|
30 | - 'field_order' => $field->field_order, |
|
31 | - 'form_id' => $field->form_id, |
|
18 | + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
19 | + |
|
20 | + $field_array = array( |
|
21 | + 'id' => $field->id, |
|
22 | + 'value' => $new_value, |
|
23 | + 'default_value' => $field->default_value, |
|
24 | + 'name' => $field->name, |
|
25 | + 'description' => $field->description, |
|
26 | + 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
27 | + 'options' => $field->options, |
|
28 | + 'required' => $field->required, |
|
29 | + 'field_key' => $field->field_key, |
|
30 | + 'field_order' => $field->field_order, |
|
31 | + 'form_id' => $field->form_id, |
|
32 | 32 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
33 | - 'reset_value' => $reset, |
|
33 | + 'reset_value' => $reset, |
|
34 | 34 | 'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0', |
35 | - ); |
|
35 | + ); |
|
36 | 36 | |
37 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
38 | - $opt_defaults['required_indicator'] = ''; |
|
37 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
38 | + $opt_defaults['required_indicator'] = ''; |
|
39 | 39 | $opt_defaults['original_type'] = $field->type; |
40 | 40 | |
41 | 41 | foreach ( $opt_defaults as $opt => $default_opt ) { |
42 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
43 | - unset($opt, $default_opt); |
|
44 | - } |
|
42 | + $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
43 | + unset($opt, $default_opt); |
|
44 | + } |
|
45 | 45 | |
46 | - unset($opt_defaults); |
|
46 | + unset($opt_defaults); |
|
47 | 47 | |
48 | - if ( $field_array['custom_html'] == '' ) { |
|
49 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
50 | - } |
|
48 | + if ( $field_array['custom_html'] == '' ) { |
|
49 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
50 | + } |
|
51 | 51 | |
52 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
53 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
52 | + $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
53 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
54 | 54 | |
55 | - $values['fields'][] = $field_array; |
|
55 | + $values['fields'][] = $field_array; |
|
56 | 56 | |
57 | - if ( ! $form || ! isset($form->id) ) { |
|
58 | - $form = FrmForm::getOne($field->form_id); |
|
59 | - } |
|
60 | - } |
|
57 | + if ( ! $form || ! isset($form->id) ) { |
|
58 | + $form = FrmForm::getOne($field->form_id); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | 62 | $form->options = maybe_unserialize( $form->options ); |
63 | 63 | if ( is_array( $form->options ) ) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $values = array_merge( $form_defaults, $values ); |
73 | 73 | |
74 | 74 | return apply_filters( 'frm_setup_new_entry', $values ); |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @since 2.05 |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Set the value for each field |
|
91 | - * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
92 | - * |
|
93 | - * @since 2.0.13 |
|
94 | - * |
|
95 | - * @param object $field - this is passed by reference since it is an object |
|
96 | - * @param boolean $reset |
|
97 | - * @param array $args |
|
98 | - * @return string|array $new_value |
|
99 | - */ |
|
90 | + * Set the value for each field |
|
91 | + * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
92 | + * |
|
93 | + * @since 2.0.13 |
|
94 | + * |
|
95 | + * @param object $field - this is passed by reference since it is an object |
|
96 | + * @param boolean $reset |
|
97 | + * @param array $args |
|
98 | + * @return string|array $new_value |
|
99 | + */ |
|
100 | 100 | private static function get_field_value_for_new_entry( $field, $reset, $args ) { |
101 | 101 | $new_value = $field->default_value; |
102 | 102 | |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | - * Check if a field has a posted value |
|
125 | - * |
|
126 | - * @since 2.01.0 |
|
127 | - * @param object $field |
|
128 | - * @param array $args |
|
129 | - * @return boolean $value_is_posted |
|
130 | - */ |
|
124 | + * Check if a field has a posted value |
|
125 | + * |
|
126 | + * @since 2.01.0 |
|
127 | + * @param object $field |
|
128 | + * @param array $args |
|
129 | + * @return boolean $value_is_posted |
|
130 | + */ |
|
131 | 131 | public static function value_is_posted( $field, $args ) { |
132 | 132 | $value_is_posted = false; |
133 | 133 | if ( $_POST ) { |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | |
146 | 146 | public static function setup_edit_vars( $values, $record ) { |
147 | 147 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
148 | - $values['form_id'] = $record->form_id; |
|
149 | - $values['is_draft'] = $record->is_draft; |
|
150 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
151 | - } |
|
148 | + $values['form_id'] = $record->form_id; |
|
149 | + $values['is_draft'] = $record->is_draft; |
|
150 | + return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
151 | + } |
|
152 | 152 | |
153 | - public static function get_admin_params( $form = null ) { |
|
153 | + public static function get_admin_params( $form = null ) { |
|
154 | 154 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' ); |
155 | 155 | return FrmForm::set_current_form( $form ); |
156 | - } |
|
156 | + } |
|
157 | 157 | |
158 | 158 | public static function set_current_form( $form_id ) { |
159 | 159 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' ); |
@@ -165,282 +165,282 @@ discard block |
||
165 | 165 | return FrmForm::get_current_form( $form_id ); |
166 | 166 | } |
167 | 167 | |
168 | - public static function get_current_form_id() { |
|
168 | + public static function get_current_form_id() { |
|
169 | 169 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' ); |
170 | 170 | return FrmForm::get_current_form_id(); |
171 | - } |
|
171 | + } |
|
172 | 172 | |
173 | - public static function maybe_get_entry( &$entry ) { |
|
173 | + public static function maybe_get_entry( &$entry ) { |
|
174 | 174 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' ); |
175 | 175 | FrmEntry::maybe_get_entry( $entry ); |
176 | - } |
|
176 | + } |
|
177 | 177 | |
178 | 178 | public static function replace_default_message( $message, $atts ) { |
179 | - if ( strpos($message, '[default-message') === false && |
|
180 | - strpos($message, '[default_message') === false && |
|
181 | - ! empty( $message ) ) { |
|
182 | - return $message; |
|
183 | - } |
|
179 | + if ( strpos($message, '[default-message') === false && |
|
180 | + strpos($message, '[default_message') === false && |
|
181 | + ! empty( $message ) ) { |
|
182 | + return $message; |
|
183 | + } |
|
184 | 184 | |
185 | - if ( empty($message) ) { |
|
186 | - $message = '[default-message]'; |
|
187 | - } |
|
185 | + if ( empty($message) ) { |
|
186 | + $message = '[default-message]'; |
|
187 | + } |
|
188 | 188 | |
189 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
189 | + preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
190 | 190 | |
191 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
191 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
192 | 192 | $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
193 | 193 | if ( ! empty( $add_atts ) ) { |
194 | - $this_atts = array_merge($atts, $add_atts); |
|
195 | - } else { |
|
196 | - $this_atts = $atts; |
|
197 | - } |
|
194 | + $this_atts = array_merge($atts, $add_atts); |
|
195 | + } else { |
|
196 | + $this_atts = $atts; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
200 | 200 | |
201 | - // Add the default message |
|
202 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
203 | - } |
|
201 | + // Add the default message |
|
202 | + $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
203 | + } |
|
204 | 204 | |
205 | - return $message; |
|
206 | - } |
|
205 | + return $message; |
|
206 | + } |
|
207 | 207 | |
208 | 208 | public static function prepare_display_value( $entry, $field, $atts ) { |
209 | 209 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
210 | 210 | |
211 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
211 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
212 | 212 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
216 | - return self::display_value($field_value, $field, $atts); |
|
217 | - } |
|
215 | + if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
216 | + return self::display_value($field_value, $field, $atts); |
|
217 | + } |
|
218 | 218 | |
219 | - // this is an embeded form |
|
220 | - $val = ''; |
|
219 | + // this is an embeded form |
|
220 | + $val = ''; |
|
221 | 221 | |
222 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
223 | - //this is a repeating section |
|
222 | + if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
223 | + //this is a repeating section |
|
224 | 224 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
225 | - } else { |
|
226 | - // get all values for this field |
|
227 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
225 | + } else { |
|
226 | + // get all values for this field |
|
227 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
228 | 228 | |
229 | - if ( $child_values ) { |
|
230 | - $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
231 | - } |
|
232 | - } |
|
229 | + if ( $child_values ) { |
|
230 | + $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
231 | + } |
|
232 | + } |
|
233 | 233 | |
234 | - $field_value = array(); |
|
234 | + $field_value = array(); |
|
235 | 235 | |
236 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
237 | - return $val; |
|
238 | - } |
|
236 | + if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
237 | + return $val; |
|
238 | + } |
|
239 | 239 | |
240 | - foreach ( $child_entries as $child_entry ) { |
|
241 | - $atts['item_id'] = $child_entry->id; |
|
242 | - $atts['post_id'] = $child_entry->post_id; |
|
240 | + foreach ( $child_entries as $child_entry ) { |
|
241 | + $atts['item_id'] = $child_entry->id; |
|
242 | + $atts['post_id'] = $child_entry->post_id; |
|
243 | 243 | |
244 | - // get the value for this field -- check for post values as well |
|
245 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
244 | + // get the value for this field -- check for post values as well |
|
245 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
246 | 246 | |
247 | - if ( $entry_val ) { |
|
248 | - // foreach entry get display_value |
|
249 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
250 | - } |
|
247 | + if ( $entry_val ) { |
|
248 | + // foreach entry get display_value |
|
249 | + $field_value[] = self::display_value($entry_val, $field, $atts); |
|
250 | + } |
|
251 | 251 | |
252 | - unset($child_entry); |
|
253 | - } |
|
252 | + unset($child_entry); |
|
253 | + } |
|
254 | 254 | |
255 | - $val = implode(', ', (array) $field_value ); |
|
255 | + $val = implode(', ', (array) $field_value ); |
|
256 | 256 | return wp_kses_post( $val ); |
257 | - } |
|
257 | + } |
|
258 | 258 | |
259 | - /** |
|
260 | - * Prepare the saved value for display |
|
261 | - * @return string |
|
262 | - */ |
|
259 | + /** |
|
260 | + * Prepare the saved value for display |
|
261 | + * @return string |
|
262 | + */ |
|
263 | 263 | public static function display_value( $value, $field, $atts = array() ) { |
264 | 264 | |
265 | - $defaults = array( |
|
266 | - 'type' => '', 'html' => false, 'show_filename' => true, |
|
267 | - 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
268 | - 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
265 | + $defaults = array( |
|
266 | + 'type' => '', 'html' => false, 'show_filename' => true, |
|
267 | + 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
268 | + 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
269 | 269 | 'return_array' => false, |
270 | - ); |
|
270 | + ); |
|
271 | 271 | |
272 | - $atts = wp_parse_args( $atts, $defaults ); |
|
273 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
272 | + $atts = wp_parse_args( $atts, $defaults ); |
|
273 | + $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
274 | 274 | |
275 | - if ( ! isset($field->field_options['post_field']) ) { |
|
276 | - $field->field_options['post_field'] = ''; |
|
277 | - } |
|
275 | + if ( ! isset($field->field_options['post_field']) ) { |
|
276 | + $field->field_options['post_field'] = ''; |
|
277 | + } |
|
278 | 278 | |
279 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
280 | - $field->field_options['custom_field'] = ''; |
|
281 | - } |
|
279 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
280 | + $field->field_options['custom_field'] = ''; |
|
281 | + } |
|
282 | 282 | |
283 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
284 | - $atts['pre_truncate'] = $atts['truncate']; |
|
285 | - $atts['truncate'] = true; |
|
286 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
283 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
284 | + $atts['pre_truncate'] = $atts['truncate']; |
|
285 | + $atts['truncate'] = true; |
|
286 | + $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
287 | 287 | |
288 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
289 | - $atts['truncate'] = $atts['pre_truncate']; |
|
290 | - } |
|
288 | + $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
289 | + $atts['truncate'] = $atts['pre_truncate']; |
|
290 | + } |
|
291 | 291 | |
292 | - if ( $value == '' ) { |
|
293 | - return $value; |
|
294 | - } |
|
292 | + if ( $value == '' ) { |
|
293 | + return $value; |
|
294 | + } |
|
295 | 295 | |
296 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
296 | + $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
297 | 297 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
298 | 298 | |
299 | - $new_value = ''; |
|
299 | + $new_value = ''; |
|
300 | 300 | |
301 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
302 | - foreach ( $value as $val ) { |
|
303 | - if ( is_array($val) ) { |
|
301 | + if ( is_array($value) && $atts['type'] != 'file' ) { |
|
302 | + foreach ( $value as $val ) { |
|
303 | + if ( is_array($val) ) { |
|
304 | 304 | //TODO: add options for display (li or ,) |
305 | - $new_value .= implode($atts['sep'], $val); |
|
306 | - if ( $atts['type'] != 'data' ) { |
|
307 | - $new_value .= '<br/>'; |
|
308 | - } |
|
309 | - } |
|
310 | - unset($val); |
|
311 | - } |
|
312 | - } |
|
313 | - |
|
314 | - if ( ! empty($new_value) ) { |
|
315 | - $value = $new_value; |
|
316 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
317 | - $value = implode($atts['sep'], $value); |
|
318 | - } |
|
319 | - |
|
320 | - if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
321 | - $value = FrmAppHelper::truncate($value, 50); |
|
322 | - } |
|
305 | + $new_value .= implode($atts['sep'], $val); |
|
306 | + if ( $atts['type'] != 'data' ) { |
|
307 | + $new_value .= '<br/>'; |
|
308 | + } |
|
309 | + } |
|
310 | + unset($val); |
|
311 | + } |
|
312 | + } |
|
313 | + |
|
314 | + if ( ! empty($new_value) ) { |
|
315 | + $value = $new_value; |
|
316 | + } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
317 | + $value = implode($atts['sep'], $value); |
|
318 | + } |
|
319 | + |
|
320 | + if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
321 | + $value = FrmAppHelper::truncate($value, 50); |
|
322 | + } |
|
323 | 323 | |
324 | 324 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
325 | 325 | $value = wp_kses_post( $value ); |
326 | 326 | } |
327 | 327 | |
328 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
329 | - } |
|
328 | + return apply_filters('frm_display_value', $value, $field, $atts); |
|
329 | + } |
|
330 | 330 | |
331 | 331 | public static function set_posted_value( $field, $value, $args ) { |
332 | - // If validating a field with "other" opt, set back to prev value now |
|
333 | - if ( isset( $args['other'] ) && $args['other'] ) { |
|
334 | - $value = $args['temp_value']; |
|
335 | - } |
|
336 | - if ( empty($args['parent_field_id']) ) { |
|
337 | - $_POST['item_meta'][ $field->id ] = $value; |
|
338 | - } else { |
|
339 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
340 | - } |
|
341 | - } |
|
332 | + // If validating a field with "other" opt, set back to prev value now |
|
333 | + if ( isset( $args['other'] ) && $args['other'] ) { |
|
334 | + $value = $args['temp_value']; |
|
335 | + } |
|
336 | + if ( empty($args['parent_field_id']) ) { |
|
337 | + $_POST['item_meta'][ $field->id ] = $value; |
|
338 | + } else { |
|
339 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
340 | + } |
|
341 | + } |
|
342 | 342 | |
343 | 343 | public static function get_posted_value( $field, &$value, $args ) { |
344 | 344 | $field_id = is_object( $field ) ? $field->id : $field; |
345 | 345 | |
346 | - if ( empty($args['parent_field_id']) ) { |
|
347 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
348 | - } else { |
|
349 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
350 | - } |
|
346 | + if ( empty($args['parent_field_id']) ) { |
|
347 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
348 | + } else { |
|
349 | + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
350 | + } |
|
351 | 351 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
352 | 352 | $value = stripslashes_deep( $value ); |
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * Check if field has an "Other" option and if any other values are posted |
|
357 | - * |
|
358 | - * @since 2.0 |
|
359 | - * |
|
360 | - * @param object $field |
|
361 | - * @param string|array $value |
|
362 | - * @param array $args |
|
363 | - */ |
|
364 | - public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
365 | - $args['other'] = false; |
|
366 | - if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
367 | - return; |
|
368 | - } |
|
369 | - |
|
370 | - // Get other value for fields in repeating section |
|
371 | - self::set_other_repeating_vals( $field, $value, $args ); |
|
372 | - |
|
373 | - // Check if there are any posted "Other" values |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * Check if field has an "Other" option and if any other values are posted |
|
357 | + * |
|
358 | + * @since 2.0 |
|
359 | + * |
|
360 | + * @param object $field |
|
361 | + * @param string|array $value |
|
362 | + * @param array $args |
|
363 | + */ |
|
364 | + public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
365 | + $args['other'] = false; |
|
366 | + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
367 | + return; |
|
368 | + } |
|
369 | + |
|
370 | + // Get other value for fields in repeating section |
|
371 | + self::set_other_repeating_vals( $field, $value, $args ); |
|
372 | + |
|
373 | + // Check if there are any posted "Other" values |
|
374 | 374 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
375 | 375 | |
376 | - // Save original value |
|
377 | - $args['temp_value'] = $value; |
|
378 | - $args['other'] = true; |
|
379 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
380 | - |
|
381 | - // Set the validation value now |
|
382 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
383 | - } |
|
384 | - } |
|
385 | - |
|
386 | - /** |
|
387 | - * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
388 | - * |
|
389 | - * @since 2.0 |
|
390 | - * |
|
391 | - * @param object $field |
|
392 | - * @param string|array $value |
|
393 | - * @param array $args |
|
394 | - */ |
|
395 | - public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
396 | - if ( ! $args['parent_field_id'] ) { |
|
397 | - return; |
|
398 | - } |
|
399 | - |
|
400 | - // Check if there are any other posted "other" values for this field |
|
376 | + // Save original value |
|
377 | + $args['temp_value'] = $value; |
|
378 | + $args['other'] = true; |
|
379 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
380 | + |
|
381 | + // Set the validation value now |
|
382 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
383 | + } |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
388 | + * |
|
389 | + * @since 2.0 |
|
390 | + * |
|
391 | + * @param object $field |
|
392 | + * @param string|array $value |
|
393 | + * @param array $args |
|
394 | + */ |
|
395 | + public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
396 | + if ( ! $args['parent_field_id'] ) { |
|
397 | + return; |
|
398 | + } |
|
399 | + |
|
400 | + // Check if there are any other posted "other" values for this field |
|
401 | 401 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
402 | - // Save original value |
|
403 | - $args['temp_value'] = $value; |
|
404 | - $args['other'] = true; |
|
405 | - |
|
406 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
407 | - |
|
408 | - // Set the validation value now |
|
409 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
410 | - } |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Modify value used for validation |
|
415 | - * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
416 | - * It also adds any text from the free text fields to the value |
|
417 | - * |
|
418 | - * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
419 | - * |
|
420 | - * @since 2.0 |
|
421 | - * |
|
422 | - * @param string|array $value |
|
423 | - * @param string|array $other_vals (usually of posted values) |
|
424 | - * @param object $field |
|
425 | - * @param array $args |
|
426 | - */ |
|
427 | - public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
428 | - // Checkboxes and multi-select dropdowns |
|
429 | - if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
430 | - // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
431 | - $value = array_merge( $value, $other_vals ); |
|
432 | - $value = array_filter( $value ); |
|
433 | - if ( count( $value ) == 0 ) { |
|
434 | - $value = ''; |
|
435 | - } |
|
436 | - } else { |
|
402 | + // Save original value |
|
403 | + $args['temp_value'] = $value; |
|
404 | + $args['other'] = true; |
|
405 | + |
|
406 | + $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
407 | + |
|
408 | + // Set the validation value now |
|
409 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
410 | + } |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Modify value used for validation |
|
415 | + * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
416 | + * It also adds any text from the free text fields to the value |
|
417 | + * |
|
418 | + * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
419 | + * |
|
420 | + * @since 2.0 |
|
421 | + * |
|
422 | + * @param string|array $value |
|
423 | + * @param string|array $other_vals (usually of posted values) |
|
424 | + * @param object $field |
|
425 | + * @param array $args |
|
426 | + */ |
|
427 | + public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
428 | + // Checkboxes and multi-select dropdowns |
|
429 | + if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
430 | + // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
431 | + $value = array_merge( $value, $other_vals ); |
|
432 | + $value = array_filter( $value ); |
|
433 | + if ( count( $value ) == 0 ) { |
|
434 | + $value = ''; |
|
435 | + } |
|
436 | + } else { |
|
437 | 437 | // Radio and dropdowns |
438 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
439 | - $other_key = reset( $other_key ); |
|
438 | + $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
439 | + $other_key = reset( $other_key ); |
|
440 | 440 | |
441 | - // Multi-select dropdown |
|
442 | - if ( is_array( $value ) ) { |
|
443 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
441 | + // Multi-select dropdown |
|
442 | + if ( is_array( $value ) ) { |
|
443 | + $o_key = array_search( $field->options[ $other_key ], $value ); |
|
444 | 444 | |
445 | 445 | if ( $o_key !== false ) { |
446 | 446 | // Modify the original value so other key will be preserved |
@@ -455,20 +455,20 @@ discard block |
||
455 | 455 | $args['temp_value'] = $value; |
456 | 456 | $value[ $other_key ] = reset( $other_vals ); |
457 | 457 | } |
458 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
459 | - $value = $other_vals; |
|
460 | - } |
|
461 | - } |
|
462 | - } |
|
458 | + } else if ( $field->options[ $other_key ] == $value ) { |
|
459 | + $value = $other_vals; |
|
460 | + } |
|
461 | + } |
|
462 | + } |
|
463 | 463 | |
464 | 464 | public static function enqueue_scripts( $params ) { |
465 | 465 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' ); |
466 | 466 | FrmFormsController::enqueue_scripts( $params ); |
467 | 467 | } |
468 | 468 | |
469 | - // Add submitted values to a string for spam checking |
|
469 | + // Add submitted values to a string for spam checking |
|
470 | 470 | public static function entry_array_to_string( $values ) { |
471 | - $content = ''; |
|
471 | + $content = ''; |
|
472 | 472 | foreach ( $values['item_meta'] as $val ) { |
473 | 473 | if ( $content != '' ) { |
474 | 474 | $content .= "\n\n"; |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | } |
484 | 484 | |
485 | 485 | return $content; |
486 | - } |
|
486 | + } |
|
487 | 487 | |
488 | 488 | /** |
489 | 489 | * Get the browser from the user agent |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | $values = array( 'name' => '', 'description' => '', 'item_key' => '' ); |
10 | 10 | |
11 | 11 | $values['fields'] = array(); |
12 | - if ( empty($fields) ) { |
|
13 | - return apply_filters('frm_setup_new_entry', $values); |
|
12 | + if ( empty( $fields ) ) { |
|
13 | + return apply_filters( 'frm_setup_new_entry', $values ); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | foreach ( (array) $fields as $field ) { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | 'default_value' => $field->default_value, |
24 | 24 | 'name' => $field->name, |
25 | 25 | 'description' => $field->description, |
26 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
26 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), |
|
27 | 27 | 'options' => $field->options, |
28 | 28 | 'required' => $field->required, |
29 | 29 | 'field_key' => $field->field_key, |
@@ -34,28 +34,28 @@ discard block |
||
34 | 34 | 'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0', |
35 | 35 | ); |
36 | 36 | |
37 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
37 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
38 | 38 | $opt_defaults['required_indicator'] = ''; |
39 | 39 | $opt_defaults['original_type'] = $field->type; |
40 | 40 | |
41 | 41 | foreach ( $opt_defaults as $opt => $default_opt ) { |
42 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
43 | - unset($opt, $default_opt); |
|
42 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; |
|
43 | + unset( $opt, $default_opt ); |
|
44 | 44 | } |
45 | 45 | |
46 | - unset($opt_defaults); |
|
46 | + unset( $opt_defaults ); |
|
47 | 47 | |
48 | 48 | if ( $field_array['custom_html'] == '' ) { |
49 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
49 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); |
|
50 | 50 | } |
51 | 51 | |
52 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
52 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
53 | 53 | $field_array = array_merge( $field->field_options, $field_array ); |
54 | 54 | |
55 | 55 | $values['fields'][] = $field_array; |
56 | 56 | |
57 | - if ( ! $form || ! isset($form->id) ) { |
|
58 | - $form = FrmForm::getOne($field->form_id); |
|
57 | + if ( ! $form || ! isset( $form->id ) ) { |
|
58 | + $form = FrmForm::getOne( $field->form_id ); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $form_defaults = FrmFormsHelper::get_default_opts(); |
68 | 68 | |
69 | 69 | $frm_settings = FrmAppHelper::get_settings(); |
70 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
70 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
71 | 71 | |
72 | 72 | $values = array_merge( $form_defaults, $values ); |
73 | 73 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | if ( ! is_array( $new_value ) ) { |
117 | - $new_value = str_replace('"', '"', $new_value); |
|
117 | + $new_value = str_replace( '"', '"', $new_value ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return $new_value; |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | if ( $_POST ) { |
134 | 134 | $repeating = isset( $args['repeating'] ) && $args['repeating']; |
135 | 135 | if ( $repeating ) { |
136 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { |
|
136 | + if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) { |
|
137 | 137 | $value_is_posted = true; |
138 | 138 | } |
139 | - } else if ( isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
139 | + } else if ( isset( $_POST['item_meta'][$field->id] ) ) { |
|
140 | 140 | $value_is_posted = true; |
141 | 141 | } |
142 | 142 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
148 | 148 | $values['form_id'] = $record->form_id; |
149 | 149 | $values['is_draft'] = $record->is_draft; |
150 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
150 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | public static function get_admin_params( $form = null ) { |
@@ -176,22 +176,22 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | public static function replace_default_message( $message, $atts ) { |
179 | - if ( strpos($message, '[default-message') === false && |
|
180 | - strpos($message, '[default_message') === false && |
|
179 | + if ( strpos( $message, '[default-message' ) === false && |
|
180 | + strpos( $message, '[default_message' ) === false && |
|
181 | 181 | ! empty( $message ) ) { |
182 | 182 | return $message; |
183 | 183 | } |
184 | 184 | |
185 | - if ( empty($message) ) { |
|
185 | + if ( empty( $message ) ) { |
|
186 | 186 | $message = '[default-message]'; |
187 | 187 | } |
188 | 188 | |
189 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
189 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
|
190 | 190 | |
191 | 191 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
192 | - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
192 | + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
193 | 193 | if ( ! empty( $add_atts ) ) { |
194 | - $this_atts = array_merge($atts, $add_atts); |
|
194 | + $this_atts = array_merge( $atts, $add_atts ); |
|
195 | 195 | } else { |
196 | 196 | $this_atts = $atts; |
197 | 197 | } |
@@ -199,32 +199,32 @@ discard block |
||
199 | 199 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
200 | 200 | |
201 | 201 | // Add the default message |
202 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
202 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | return $message; |
206 | 206 | } |
207 | 207 | |
208 | 208 | public static function prepare_display_value( $entry, $field, $atts ) { |
209 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
209 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
210 | 210 | |
211 | 211 | if ( FrmAppHelper::pro_is_installed() ) { |
212 | 212 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
213 | 213 | } |
214 | 214 | |
215 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
216 | - return self::display_value($field_value, $field, $atts); |
|
215 | + if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
|
216 | + return self::display_value( $field_value, $field, $atts ); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | // this is an embeded form |
220 | 220 | $val = ''; |
221 | 221 | |
222 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
222 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
|
223 | 223 | //this is a repeating section |
224 | 224 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
225 | 225 | } else { |
226 | 226 | // get all values for this field |
227 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
227 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
228 | 228 | |
229 | 229 | if ( $child_values ) { |
230 | 230 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | $field_value = array(); |
235 | 235 | |
236 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
236 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
237 | 237 | return $val; |
238 | 238 | } |
239 | 239 | |
@@ -242,17 +242,17 @@ discard block |
||
242 | 242 | $atts['post_id'] = $child_entry->post_id; |
243 | 243 | |
244 | 244 | // get the value for this field -- check for post values as well |
245 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
245 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
|
246 | 246 | |
247 | 247 | if ( $entry_val ) { |
248 | 248 | // foreach entry get display_value |
249 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
249 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); |
|
250 | 250 | } |
251 | 251 | |
252 | - unset($child_entry); |
|
252 | + unset( $child_entry ); |
|
253 | 253 | } |
254 | 254 | |
255 | - $val = implode(', ', (array) $field_value ); |
|
255 | + $val = implode( ', ', (array) $field_value ); |
|
256 | 256 | return wp_kses_post( $val ); |
257 | 257 | } |
258 | 258 | |
@@ -270,22 +270,22 @@ discard block |
||
270 | 270 | ); |
271 | 271 | |
272 | 272 | $atts = wp_parse_args( $atts, $defaults ); |
273 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
273 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
|
274 | 274 | |
275 | - if ( ! isset($field->field_options['post_field']) ) { |
|
275 | + if ( ! isset( $field->field_options['post_field'] ) ) { |
|
276 | 276 | $field->field_options['post_field'] = ''; |
277 | 277 | } |
278 | 278 | |
279 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
279 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
280 | 280 | $field->field_options['custom_field'] = ''; |
281 | 281 | } |
282 | 282 | |
283 | 283 | if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
284 | 284 | $atts['pre_truncate'] = $atts['truncate']; |
285 | 285 | $atts['truncate'] = true; |
286 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
286 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
|
287 | 287 | |
288 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
288 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
|
289 | 289 | $atts['truncate'] = $atts['pre_truncate']; |
290 | 290 | } |
291 | 291 | |
@@ -293,39 +293,39 @@ discard block |
||
293 | 293 | return $value; |
294 | 294 | } |
295 | 295 | |
296 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
296 | + $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts ); |
|
297 | 297 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
298 | 298 | |
299 | 299 | $new_value = ''; |
300 | 300 | |
301 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
301 | + if ( is_array( $value ) && $atts['type'] != 'file' ) { |
|
302 | 302 | foreach ( $value as $val ) { |
303 | - if ( is_array($val) ) { |
|
303 | + if ( is_array( $val ) ) { |
|
304 | 304 | //TODO: add options for display (li or ,) |
305 | - $new_value .= implode($atts['sep'], $val); |
|
305 | + $new_value .= implode( $atts['sep'], $val ); |
|
306 | 306 | if ( $atts['type'] != 'data' ) { |
307 | 307 | $new_value .= '<br/>'; |
308 | 308 | } |
309 | 309 | } |
310 | - unset($val); |
|
310 | + unset( $val ); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - if ( ! empty($new_value) ) { |
|
314 | + if ( ! empty( $new_value ) ) { |
|
315 | 315 | $value = $new_value; |
316 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
317 | - $value = implode($atts['sep'], $value); |
|
316 | + } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
317 | + $value = implode( $atts['sep'], $value ); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
321 | - $value = FrmAppHelper::truncate($value, 50); |
|
321 | + $value = FrmAppHelper::truncate( $value, 50 ); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
325 | 325 | $value = wp_kses_post( $value ); |
326 | 326 | } |
327 | 327 | |
328 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
328 | + return apply_filters( 'frm_display_value', $value, $field, $atts ); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | public static function set_posted_value( $field, $value, $args ) { |
@@ -333,20 +333,20 @@ discard block |
||
333 | 333 | if ( isset( $args['other'] ) && $args['other'] ) { |
334 | 334 | $value = $args['temp_value']; |
335 | 335 | } |
336 | - if ( empty($args['parent_field_id']) ) { |
|
337 | - $_POST['item_meta'][ $field->id ] = $value; |
|
336 | + if ( empty( $args['parent_field_id'] ) ) { |
|
337 | + $_POST['item_meta'][$field->id] = $value; |
|
338 | 338 | } else { |
339 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
339 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | 343 | public static function get_posted_value( $field, &$value, $args ) { |
344 | 344 | $field_id = is_object( $field ) ? $field->id : $field; |
345 | 345 | |
346 | - if ( empty($args['parent_field_id']) ) { |
|
347 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
346 | + if ( empty( $args['parent_field_id'] ) ) { |
|
347 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; |
|
348 | 348 | } else { |
349 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
349 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : ''; |
|
350 | 350 | } |
351 | 351 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
352 | 352 | $value = stripslashes_deep( $value ); |
@@ -371,12 +371,12 @@ discard block |
||
371 | 371 | self::set_other_repeating_vals( $field, $value, $args ); |
372 | 372 | |
373 | 373 | // Check if there are any posted "Other" values |
374 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
374 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
375 | 375 | |
376 | 376 | // Save original value |
377 | 377 | $args['temp_value'] = $value; |
378 | 378 | $args['other'] = true; |
379 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
379 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); |
|
380 | 380 | |
381 | 381 | // Set the validation value now |
382 | 382 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | } |
399 | 399 | |
400 | 400 | // Check if there are any other posted "other" values for this field |
401 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
401 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
402 | 402 | // Save original value |
403 | 403 | $args['temp_value'] = $value; |
404 | 404 | $args['other'] = true; |
405 | 405 | |
406 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
406 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; |
|
407 | 407 | |
408 | 408 | // Set the validation value now |
409 | 409 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -435,27 +435,27 @@ discard block |
||
435 | 435 | } |
436 | 436 | } else { |
437 | 437 | // Radio and dropdowns |
438 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
438 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); |
|
439 | 439 | $other_key = reset( $other_key ); |
440 | 440 | |
441 | 441 | // Multi-select dropdown |
442 | 442 | if ( is_array( $value ) ) { |
443 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
443 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
444 | 444 | |
445 | 445 | if ( $o_key !== false ) { |
446 | 446 | // Modify the original value so other key will be preserved |
447 | - $value[ $other_key ] = $value[ $o_key ]; |
|
447 | + $value[$other_key] = $value[$o_key]; |
|
448 | 448 | |
449 | 449 | // By default, the array keys will be numeric for multi-select dropdowns |
450 | 450 | // If going backwards and forwards between pages, the array key will match the other key |
451 | 451 | if ( $o_key != $other_key ) { |
452 | - unset( $value[ $o_key ] ); |
|
452 | + unset( $value[$o_key] ); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | $args['temp_value'] = $value; |
456 | - $value[ $other_key ] = reset( $other_vals ); |
|
456 | + $value[$other_key] = reset( $other_vals ); |
|
457 | 457 | } |
458 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
458 | + } else if ( $field->options[$other_key] == $value ) { |
|
459 | 459 | $value = $other_vals; |
460 | 460 | } |
461 | 461 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | $content .= "\n\n"; |
475 | 475 | } |
476 | 476 | |
477 | - if ( is_array($val) ) { |
|
477 | + if ( is_array( $val ) ) { |
|
478 | 478 | $val = FrmAppHelper::array_flatten( $val ); |
479 | 479 | $val = implode( ', ', $val ); |
480 | 480 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers |
539 | 539 | |
540 | 540 | // see how many we have |
541 | - $i = count($matches['browser']); |
|
541 | + $i = count( $matches['browser'] ); |
|
542 | 542 | |
543 | 543 | if ( $i > 1 ) { |
544 | 544 | //we will have two since we are not using 'other' argument yet |