@@ -64,8 +64,8 @@ |
||
64 | 64 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=destroy&id=' . $style->ID ) ); ?>" id="frm_delete_style" class="submitdelete deletion" onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to delete that style?', 'formidable' ) ?>')"><?php _e( 'Delete Style', 'formidable' ) ?></a> |
65 | 65 | <?php } ?> |
66 | 66 | <?php |
67 | - if ( $style->ID ) { |
|
68 | - echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
67 | + if ( $style->ID ) { |
|
68 | + echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
69 | 69 | } ?> |
70 | 70 | <div class="publishing-action"> |
71 | 71 | <input type="button" value="<?php esc_attr_e( 'Reset to Default', 'formidable' ) ?>" class="button-secondary frm_reset_style" /> |
@@ -2,14 +2,14 @@ discard block |
||
2 | 2 | <div class="wrap"> |
3 | 3 | <?php FrmStylesHelper::style_menu(); ?> |
4 | 4 | |
5 | - <?php include(FrmAppHelper::plugin_path() .'/classes/views/shared/errors.php'); ?> |
|
5 | + <?php include( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); ?> |
|
6 | 6 | |
7 | 7 | <?php do_action( 'frm_style_switcher', $style, $styles ) ?> |
8 | 8 | |
9 | 9 | <form id="frm_styling_form" action="" name="frm_styling_form" method="post"> |
10 | 10 | <input type="hidden" name="ID" value="<?php echo esc_attr( $style->ID ) ?>" /> |
11 | 11 | <input type="hidden" name="frm_action" value="save" /> |
12 | - <textarea name="<?php echo esc_attr( $frm_style->get_field_name('custom_css') ) ?>" class="frm_hidden"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
12 | + <textarea name="<?php echo esc_attr( $frm_style->get_field_name( 'custom_css' ) ) ?>" class="frm_hidden"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
13 | 13 | <?php wp_nonce_field( 'frm_style_nonce', 'frm_style' ); ?> |
14 | 14 | |
15 | 15 | <div id="nav-menus-frame"> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | <div class="styling_settings"> |
20 | 20 | <input type="hidden" name="style_name" value="frm_style_<?php echo esc_attr( $style->post_name ) ?>" /> |
21 | - <?php FrmStylesController::do_accordion_sections( FrmStylesController::$screen, 'side', compact('style', 'frm_style') ); ?> |
|
21 | + <?php FrmStylesController::do_accordion_sections( FrmStylesController::$screen, 'side', compact( 'style', 'frm_style' ) ); ?> |
|
22 | 22 | </div> |
23 | 23 | |
24 | 24 | </div><!-- /#menu-settings-column --> |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | <div class="major-publishing-actions"> |
32 | 32 | <label class="menu-name-label howto open-label" for="menu-name"> |
33 | 33 | <span><?php _e( 'Style Name', 'formidable' ) ?></span> |
34 | - <input id="menu-name" name="<?php echo esc_attr( $frm_style->get_field_name('post_title', '') ); ?>" type="text" class="menu-name regular-text menu-item-textbox" title="<?php esc_attr_e( 'Enter style name here', 'formidable' ) ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
34 | + <input id="menu-name" name="<?php echo esc_attr( $frm_style->get_field_name( 'post_title', '' ) ); ?>" type="text" class="menu-name regular-text menu-item-textbox" title="<?php esc_attr_e( 'Enter style name here', 'formidable' ) ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
35 | 35 | </label> |
36 | 36 | |
37 | - <input name="prev_menu_order" type="hidden" value="<?php echo esc_attr($style->menu_order) ?>" /> |
|
37 | + <input name="prev_menu_order" type="hidden" value="<?php echo esc_attr( $style->menu_order ) ?>" /> |
|
38 | 38 | <label class="menu-name-label howto open-label default-style-box" for="menu_order"> |
39 | 39 | <span> |
40 | 40 | <?php if ( $style->menu_order ) { ?> |
41 | - <input name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" type="hidden" value="1" /> |
|
42 | - <input id="menu_order" disabled="disabled" type="checkbox" value="1" <?php checked($style->menu_order, 1) ?> /> |
|
41 | + <input name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" type="hidden" value="1" /> |
|
42 | + <input id="menu_order" disabled="disabled" type="checkbox" value="1" <?php checked( $style->menu_order, 1 ) ?> /> |
|
43 | 43 | <?php } else { ?> |
44 | - <input id="menu_order" name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" type="checkbox" value="1" <?php checked($style->menu_order, 1) ?> /> |
|
44 | + <input id="menu_order" name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" type="checkbox" value="1" <?php checked( $style->menu_order, 1 ) ?> /> |
|
45 | 45 | <?php } ?> |
46 | 46 | <?php _e( 'Make default style', 'formidable' ) ?></span> |
47 | 47 | </label> |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | <div id="post-body"> |
55 | 55 | <div id="post-body-content"> |
56 | 56 | |
57 | - <?php include( dirname(__FILE__) .'/_sample_form.php') ?> |
|
57 | + <?php include( dirname( __FILE__ ) . '/_sample_form.php' ) ?> |
|
58 | 58 | |
59 | 59 | </div><!-- /#post-body-content --> |
60 | 60 | </div><!-- /#post-body --> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <?php } ?> |
66 | 66 | <?php |
67 | 67 | if ( $style->ID ) { |
68 | - echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
68 | + echo '<span class="howto"><span>.frm_style_' . esc_attr( $style->post_name ) . '</span></span>'; |
|
69 | 69 | } ?> |
70 | 70 | <div class="publishing-action"> |
71 | 71 | <input type="button" value="<?php esc_attr_e( 'Reset to Default', 'formidable' ) ?>" class="button-secondary frm_reset_style" /> |
@@ -179,7 +179,7 @@ |
||
179 | 179 | * @access public |
180 | 180 | * |
181 | 181 | * @param string $name Property to check if set. |
182 | - * @return bool Whether the property is set. |
|
182 | + * @return boolean|null Whether the property is set. |
|
183 | 183 | */ |
184 | 184 | public function __isset( $name ) { |
185 | 185 | if ( in_array( $name, $this->compat_fields ) ) { |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | protected $modes = array(); |
68 | 68 | |
69 | 69 | /** |
70 | - * |
|
71 | - * @var array |
|
72 | - */ |
|
73 | - protected $params; |
|
70 | + * |
|
71 | + * @var array |
|
72 | + */ |
|
73 | + protected $params; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Stores the value returned by ->get_column_info() |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | 'single_row_columns' ); |
88 | 88 | |
89 | 89 | /** |
90 | - * Construct the table object |
|
91 | - */ |
|
90 | + * Construct the table object |
|
91 | + */ |
|
92 | 92 | public function __construct( $args ) { |
93 | - $args = wp_parse_args( $args, array( |
|
93 | + $args = wp_parse_args( $args, array( |
|
94 | 94 | 'params' => array(), |
95 | 95 | 'plural' => '', |
96 | 96 | 'singular' => '', |
@@ -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 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
106 | 106 | |
107 | - if ( !$args['plural'] ) |
|
107 | + if ( ! $args['plural'] ) |
|
108 | 108 | $args['plural'] = $this->screen->base; |
109 | 109 | |
110 | 110 | $args['plural'] = sanitize_key( $args['plural'] ); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'per_page' => 0, |
246 | 246 | ) ); |
247 | 247 | |
248 | - if ( !$args['total_pages'] && $args['per_page'] > 0 ) |
|
248 | + if ( ! $args['total_pages'] && $args['per_page'] > 0 ) |
|
249 | 249 | $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
250 | 250 | |
251 | 251 | // Redirect if page number is invalid and headers are not already sent. |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @return bool |
285 | 285 | */ |
286 | 286 | public function has_items() { |
287 | - return !empty( $this->items ); |
|
287 | + return ! empty( $this->items ); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @param string $input_id The search input id |
308 | 308 | */ |
309 | 309 | public function search_box( $text, $input_id ) { |
310 | - if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) |
|
310 | + if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) |
|
311 | 311 | return; |
312 | 312 | |
313 | 313 | $input_id = $input_id . '-search-input'; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | <p class="search-box"> |
325 | 325 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
326 | 326 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
327 | - <?php submit_button( $text, 'button', '', false, array('id' => 'search-submit') ); ?> |
|
327 | + <?php submit_button( $text, 'button', '', false, array( 'id' => 'search-submit' ) ); ?> |
|
328 | 328 | </p> |
329 | 329 | <?php |
330 | 330 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | |
368 | 368 | echo "<ul class='subsubsub'>\n"; |
369 | 369 | foreach ( $views as $class => $view ) { |
370 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
370 | + $views[$class] = "\t<li class='$class'>$view"; |
|
371 | 371 | } |
372 | 372 | echo implode( " |</li>\n", $views ) . "</li>\n"; |
373 | 373 | echo "</ul>"; |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | $action_count = count( $actions ); |
472 | 472 | $i = 0; |
473 | 473 | |
474 | - if ( !$action_count ) |
|
474 | + if ( ! $action_count ) |
|
475 | 475 | return ''; |
476 | 476 | |
477 | 477 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
478 | 478 | foreach ( $actions as $action => $link ) { |
479 | - ++$i; |
|
479 | + ++ $i; |
|
480 | 480 | ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
481 | 481 | $out .= "<span class='$action'>$link$sep</span>"; |
482 | 482 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | |
533 | 533 | $month_count = count( $months ); |
534 | 534 | |
535 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
535 | + if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
536 | 536 | return; |
537 | 537 | |
538 | 538 | $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</span>'; |
749 | 749 | } else { |
750 | 750 | $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
751 | - esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ), |
|
751 | + esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ), |
|
752 | 752 | __( 'Previous page' ), |
753 | 753 | '‹' |
754 | 754 | ); |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</span>'; |
772 | 772 | } else { |
773 | 773 | $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
774 | - esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ), |
|
774 | + esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ), |
|
775 | 775 | __( 'Next page' ), |
776 | 776 | '›' |
777 | 777 | ); |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | |
835 | 835 | // We need a primary defined so responsive views show something, |
836 | 836 | // so let's fall back to the first non-checkbox column. |
837 | - foreach( $columns as $col => $column_name ) { |
|
837 | + foreach ( $columns as $col => $column_name ) { |
|
838 | 838 | if ( 'cb' === $col ) { |
839 | 839 | continue; |
840 | 840 | } |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | |
861 | 861 | // If the primary column doesn't exist fall back to the |
862 | 862 | // first non-checkbox column. |
863 | - if ( ! isset( $columns[ $default ] ) ) { |
|
863 | + if ( ! isset( $columns[$default] ) ) { |
|
864 | 864 | $default = FrmListHelper::get_default_primary_column_name(); |
865 | 865 | } |
866 | 866 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | */ |
875 | 875 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
876 | 876 | |
877 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
877 | + if ( empty( $column ) || ! isset( $columns[$column] ) ) { |
|
878 | 878 | $column = $default; |
879 | 879 | } |
880 | 880 | |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | // In 4.3, we added a fourth argument for primary column. |
897 | 897 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
898 | 898 | foreach ( $this->_column_headers as $key => $value ) { |
899 | - $column_headers[ $key ] = $value; |
|
899 | + $column_headers[$key] = $value; |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | return $column_headers; |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | continue; |
925 | 925 | |
926 | 926 | $data = (array) $data; |
927 | - if ( !isset( $data[1] ) ) |
|
927 | + if ( ! isset( $data[1] ) ) |
|
928 | 928 | $data[1] = false; |
929 | 929 | |
930 | 930 | $sortable[$id] = $data; |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | static $cb_counter = 1; |
981 | 981 | $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
982 | 982 | . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
983 | - $cb_counter++; |
|
983 | + $cb_counter ++; |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | foreach ( $columns as $column_key => $column_display_name ) { |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
1020 | 1020 | $id = $with_id ? "id='$column_key'" : ''; |
1021 | 1021 | |
1022 | - if ( !empty( $class ) ) |
|
1022 | + if ( ! empty( $class ) ) |
|
1023 | 1023 | $class = "class='" . join( ' ', $class ) . "'"; |
1024 | 1024 | |
1025 | 1025 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
@@ -104,8 +104,9 @@ discard block |
||
104 | 104 | |
105 | 105 | add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
106 | 106 | |
107 | - if ( !$args['plural'] ) |
|
108 | - $args['plural'] = $this->screen->base; |
|
107 | + if ( !$args['plural'] ) { |
|
108 | + $args['plural'] = $this->screen->base; |
|
109 | + } |
|
109 | 110 | |
110 | 111 | $args['plural'] = sanitize_key( $args['plural'] ); |
111 | 112 | $args['singular'] = sanitize_key( $args['singular'] ); |
@@ -245,8 +246,9 @@ discard block |
||
245 | 246 | 'per_page' => 0, |
246 | 247 | ) ); |
247 | 248 | |
248 | - if ( !$args['total_pages'] && $args['per_page'] > 0 ) |
|
249 | - $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
249 | + if ( !$args['total_pages'] && $args['per_page'] > 0 ) { |
|
250 | + $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
251 | + } |
|
250 | 252 | |
251 | 253 | // Redirect if page number is invalid and headers are not already sent. |
252 | 254 | if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
@@ -268,11 +270,13 @@ discard block |
||
268 | 270 | * @return int Number of items that correspond to the given pagination argument. |
269 | 271 | */ |
270 | 272 | public function get_pagination_arg( $key ) { |
271 | - if ( 'page' == $key ) |
|
272 | - return $this->get_pagenum(); |
|
273 | + if ( 'page' == $key ) { |
|
274 | + return $this->get_pagenum(); |
|
275 | + } |
|
273 | 276 | |
274 | - if ( isset( $this->_pagination_args[$key] ) ) |
|
275 | - return $this->_pagination_args[$key]; |
|
277 | + if ( isset( $this->_pagination_args[$key] ) ) { |
|
278 | + return $this->_pagination_args[$key]; |
|
279 | + } |
|
276 | 280 | } |
277 | 281 | |
278 | 282 | /** |
@@ -307,20 +311,25 @@ discard block |
||
307 | 311 | * @param string $input_id The search input id |
308 | 312 | */ |
309 | 313 | public function search_box( $text, $input_id ) { |
310 | - if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) |
|
311 | - return; |
|
314 | + if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) { |
|
315 | + return; |
|
316 | + } |
|
312 | 317 | |
313 | 318 | $input_id = $input_id . '-search-input'; |
314 | 319 | |
315 | - if ( ! empty( $_REQUEST['orderby'] ) ) |
|
316 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
317 | - if ( ! empty( $_REQUEST['order'] ) ) |
|
318 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
319 | - if ( ! empty( $_REQUEST['post_mime_type'] ) ) |
|
320 | - echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
321 | - if ( ! empty( $_REQUEST['detached'] ) ) |
|
322 | - echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
323 | -?> |
|
320 | + if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
321 | + echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
322 | + } |
|
323 | + if ( ! empty( $_REQUEST['order'] ) ) { |
|
324 | + echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
325 | + } |
|
326 | + if ( ! empty( $_REQUEST['post_mime_type'] ) ) { |
|
327 | + echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
328 | + } |
|
329 | + if ( ! empty( $_REQUEST['detached'] ) ) { |
|
330 | + echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
331 | + } |
|
332 | + ?> |
|
324 | 333 | <p class="search-box"> |
325 | 334 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
326 | 335 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
@@ -362,8 +371,9 @@ discard block |
||
362 | 371 | */ |
363 | 372 | $views = apply_filters( "views_{$this->screen->id}", $views ); |
364 | 373 | |
365 | - if ( empty( $views ) ) |
|
366 | - return; |
|
374 | + if ( empty( $views ) ) { |
|
375 | + return; |
|
376 | + } |
|
367 | 377 | |
368 | 378 | echo "<ul class='subsubsub'>\n"; |
369 | 379 | foreach ( $views as $class => $view ) { |
@@ -417,8 +427,9 @@ discard block |
||
417 | 427 | $two = '2'; |
418 | 428 | } |
419 | 429 | |
420 | - if ( empty( $this->_actions ) ) |
|
421 | - return; |
|
430 | + if ( empty( $this->_actions ) ) { |
|
431 | + return; |
|
432 | + } |
|
422 | 433 | |
423 | 434 | echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . __( 'Select bulk action' ) . "</label>"; |
424 | 435 | echo "<select name='action$two' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n"; |
@@ -445,14 +456,17 @@ discard block |
||
445 | 456 | * @return string|false The action name or False if no action was selected |
446 | 457 | */ |
447 | 458 | public function current_action() { |
448 | - if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) |
|
449 | - return false; |
|
459 | + if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { |
|
460 | + return false; |
|
461 | + } |
|
450 | 462 | |
451 | - if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) |
|
452 | - return $_REQUEST['action']; |
|
463 | + if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) { |
|
464 | + return $_REQUEST['action']; |
|
465 | + } |
|
453 | 466 | |
454 | - if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) |
|
455 | - return $_REQUEST['action2']; |
|
467 | + if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) { |
|
468 | + return $_REQUEST['action2']; |
|
469 | + } |
|
456 | 470 | |
457 | 471 | return false; |
458 | 472 | } |
@@ -471,8 +485,9 @@ discard block |
||
471 | 485 | $action_count = count( $actions ); |
472 | 486 | $i = 0; |
473 | 487 | |
474 | - if ( !$action_count ) |
|
475 | - return ''; |
|
488 | + if ( !$action_count ) { |
|
489 | + return ''; |
|
490 | + } |
|
476 | 491 | |
477 | 492 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
478 | 493 | foreach ( $actions as $action => $link ) { |
@@ -532,8 +547,9 @@ discard block |
||
532 | 547 | |
533 | 548 | $month_count = count( $months ); |
534 | 549 | |
535 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
536 | - return; |
|
550 | + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { |
|
551 | + return; |
|
552 | + } |
|
537 | 553 | |
538 | 554 | $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
539 | 555 | ?> |
@@ -542,8 +558,9 @@ discard block |
||
542 | 558 | <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
543 | 559 | <?php |
544 | 560 | foreach ( $months as $arc_row ) { |
545 | - if ( 0 == $arc_row->year ) |
|
546 | - continue; |
|
561 | + if ( 0 == $arc_row->year ) { |
|
562 | + continue; |
|
563 | + } |
|
547 | 564 | |
548 | 565 | $month = zeroise( $arc_row->month, 2 ); |
549 | 566 | $year = $arc_row->year; |
@@ -575,8 +592,9 @@ discard block |
||
575 | 592 | <?php |
576 | 593 | foreach ( $this->modes as $mode => $title ) { |
577 | 594 | $classes = array( 'view-' . $mode ); |
578 | - if ( $current_mode == $mode ) |
|
579 | - $classes[] = 'current'; |
|
595 | + if ( $current_mode == $mode ) { |
|
596 | + $classes[] = 'current'; |
|
597 | + } |
|
580 | 598 | printf( |
581 | 599 | "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
582 | 600 | esc_url( add_query_arg( 'mode', $mode ) ), |
@@ -647,8 +665,9 @@ discard block |
||
647 | 665 | public function get_pagenum() { |
648 | 666 | $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; |
649 | 667 | |
650 | - if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) |
|
651 | - $pagenum = $this->_pagination_args['total_pages']; |
|
668 | + if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) { |
|
669 | + $pagenum = $this->_pagination_args['total_pages']; |
|
670 | + } |
|
652 | 671 | |
653 | 672 | return max( 1, $pagenum ); |
654 | 673 | } |
@@ -665,8 +684,9 @@ discard block |
||
665 | 684 | */ |
666 | 685 | protected function get_items_per_page( $option, $default = 20 ) { |
667 | 686 | $per_page = (int) get_user_option( $option ); |
668 | - if ( empty( $per_page ) || $per_page < 1 ) |
|
669 | - $per_page = $default; |
|
687 | + if ( empty( $per_page ) || $per_page < 1 ) { |
|
688 | + $per_page = $default; |
|
689 | + } |
|
670 | 690 | |
671 | 691 | /** |
672 | 692 | * Filter the number of items to be displayed on each page of the list table. |
@@ -920,12 +940,14 @@ discard block |
||
920 | 940 | |
921 | 941 | $sortable = array(); |
922 | 942 | foreach ( $_sortable as $id => $data ) { |
923 | - if ( empty( $data ) ) |
|
924 | - continue; |
|
943 | + if ( empty( $data ) ) { |
|
944 | + continue; |
|
945 | + } |
|
925 | 946 | |
926 | 947 | $data = (array) $data; |
927 | - if ( !isset( $data[1] ) ) |
|
928 | - $data[1] = false; |
|
948 | + if ( !isset( $data[1] ) ) { |
|
949 | + $data[1] = false; |
|
950 | + } |
|
929 | 951 | |
930 | 952 | $sortable[$id] = $data; |
931 | 953 | } |
@@ -966,15 +988,17 @@ discard block |
||
966 | 988 | $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
967 | 989 | $current_url = remove_query_arg( 'paged', $current_url ); |
968 | 990 | |
969 | - if ( isset( $_GET['orderby'] ) ) |
|
970 | - $current_orderby = $_GET['orderby']; |
|
971 | - else |
|
972 | - $current_orderby = ''; |
|
991 | + if ( isset( $_GET['orderby'] ) ) { |
|
992 | + $current_orderby = $_GET['orderby']; |
|
993 | + } else { |
|
994 | + $current_orderby = ''; |
|
995 | + } |
|
973 | 996 | |
974 | - if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) |
|
975 | - $current_order = 'desc'; |
|
976 | - else |
|
977 | - $current_order = 'asc'; |
|
997 | + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { |
|
998 | + $current_order = 'desc'; |
|
999 | + } else { |
|
1000 | + $current_order = 'asc'; |
|
1001 | + } |
|
978 | 1002 | |
979 | 1003 | if ( ! empty( $columns['cb'] ) ) { |
980 | 1004 | static $cb_counter = 1; |
@@ -990,10 +1014,11 @@ discard block |
||
990 | 1014 | $class[] = 'hidden'; |
991 | 1015 | } |
992 | 1016 | |
993 | - if ( 'cb' == $column_key ) |
|
994 | - $class[] = 'check-column'; |
|
995 | - elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) |
|
996 | - $class[] = 'num'; |
|
1017 | + if ( 'cb' == $column_key ) { |
|
1018 | + $class[] = 'check-column'; |
|
1019 | + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) { |
|
1020 | + $class[] = 'num'; |
|
1021 | + } |
|
997 | 1022 | |
998 | 1023 | if ( $column_key === $primary ) { |
999 | 1024 | $class[] = 'column-primary'; |
@@ -1019,8 +1044,9 @@ discard block |
||
1019 | 1044 | $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
1020 | 1045 | $id = $with_id ? "id='$column_key'" : ''; |
1021 | 1046 | |
1022 | - if ( !empty( $class ) ) |
|
1023 | - $class = "class='" . join( ' ', $class ) . "'"; |
|
1047 | + if ( !empty( $class ) ) { |
|
1048 | + $class = "class='" . join( ' ', $class ) . "'"; |
|
1049 | + } |
|
1024 | 1050 | |
1025 | 1051 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
1026 | 1052 | } |
@@ -1082,9 +1108,10 @@ discard block |
||
1082 | 1108 | * @param string $which |
1083 | 1109 | */ |
1084 | 1110 | protected function display_tablenav( $which ) { |
1085 | - if ( 'top' == $which ) |
|
1086 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
1087 | -?> |
|
1111 | + if ( 'top' == $which ) { |
|
1112 | + wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
1113 | + } |
|
1114 | + ?> |
|
1088 | 1115 | <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
1089 | 1116 | |
1090 | 1117 | <div class="alignleft actions bulkactions"> |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmEntryValidate { |
4 | - public static function validate( $values, $exclude = false ) { |
|
5 | - global $wpdb; |
|
4 | + public static function validate( $values, $exclude = false ) { |
|
5 | + global $wpdb; |
|
6 | 6 | |
7 | - FrmEntry::sanitize_entry_post( $values ); |
|
8 | - $errors = array(); |
|
7 | + FrmEntry::sanitize_entry_post( $values ); |
|
8 | + $errors = array(); |
|
9 | 9 | |
10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
11 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
12 | - return $errors; |
|
13 | - } |
|
10 | + if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
11 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
12 | + return $errors; |
|
13 | + } |
|
14 | 14 | |
15 | 15 | if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
16 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
17 | - } |
|
16 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
17 | + } |
|
18 | 18 | |
19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
20 | - $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
21 | - } |
|
19 | + if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
20 | + $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
21 | + } |
|
22 | 22 | |
23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
23 | + $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
24 | 24 | // Don't get subfields |
25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,46 +28,46 @@ discard block |
||
28 | 28 | $where['fi.type not'] = $exclude; |
29 | 29 | } |
30 | 30 | |
31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
31 | + $posted_fields = FrmField::getAll($where, 'field_order'); |
|
32 | 32 | |
33 | - // Pass exclude value to validate_field function so it can be used for repeating sections |
|
34 | - $args = array( 'exclude' => $exclude ); |
|
33 | + // Pass exclude value to validate_field function so it can be used for repeating sections |
|
34 | + $args = array( 'exclude' => $exclude ); |
|
35 | 35 | |
36 | - foreach ( $posted_fields as $posted_field ) { |
|
37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
38 | - unset($posted_field); |
|
39 | - } |
|
36 | + foreach ( $posted_fields as $posted_field ) { |
|
37 | + self::validate_field($posted_field, $errors, $values, $args); |
|
38 | + unset($posted_field); |
|
39 | + } |
|
40 | 40 | |
41 | - // check for spam |
|
42 | - self::spam_check( $exclude, $values, $errors ); |
|
41 | + // check for spam |
|
42 | + self::spam_check( $exclude, $values, $errors ); |
|
43 | 43 | |
44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
45 | 45 | |
46 | - return $errors; |
|
47 | - } |
|
46 | + return $errors; |
|
47 | + } |
|
48 | 48 | |
49 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
50 | - $defaults = array( |
|
51 | - 'id' => $posted_field->id, |
|
52 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
53 | - 'key_pointer' => '', // the pointer in the posted array |
|
54 | - 'exclude' => array(), // exclude these field types from validation |
|
55 | - ); |
|
56 | - $args = wp_parse_args( $args, $defaults ); |
|
49 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
50 | + $defaults = array( |
|
51 | + 'id' => $posted_field->id, |
|
52 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
53 | + 'key_pointer' => '', // the pointer in the posted array |
|
54 | + 'exclude' => array(), // exclude these field types from validation |
|
55 | + ); |
|
56 | + $args = wp_parse_args( $args, $defaults ); |
|
57 | 57 | |
58 | - if ( empty($args['parent_field_id']) ) { |
|
58 | + if ( empty($args['parent_field_id']) ) { |
|
59 | 59 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
60 | - } else { |
|
61 | - // value is from a nested form |
|
62 | - $value = $values; |
|
63 | - } |
|
60 | + } else { |
|
61 | + // value is from a nested form |
|
62 | + $value = $values; |
|
63 | + } |
|
64 | 64 | |
65 | - // Check for values in "Other" fields |
|
66 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
65 | + // Check for values in "Other" fields |
|
66 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
67 | 67 | |
68 | - if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
69 | - $value = ''; |
|
70 | - } |
|
68 | + if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
69 | + $value = ''; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | // Check for an array with only one value |
73 | 73 | // Don't reset values in "Other" fields because array keys need to be preserved |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | $value = reset($value); |
76 | 76 | } |
77 | 77 | |
78 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
78 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
79 | 79 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
80 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
81 | - $_POST['item_name'] = $value; |
|
82 | - } |
|
80 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
81 | + $_POST['item_name'] = $value; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | if ( $value != '' ) { |
85 | 85 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -88,41 +88,41 @@ discard block |
||
88 | 88 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
89 | 89 | } |
90 | 90 | |
91 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
91 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
92 | 92 | |
93 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
93 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
94 | 94 | |
95 | - $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
96 | - } |
|
95 | + $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
99 | 99 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
100 | - return; |
|
101 | - } |
|
102 | - |
|
103 | - if ( trim($value) == 'http://' ) { |
|
104 | - $value = ''; |
|
105 | - } else { |
|
106 | - $value = esc_url_raw( $value ); |
|
107 | - $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
108 | - } |
|
109 | - |
|
110 | - //validate the url format |
|
111 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
100 | + return; |
|
101 | + } |
|
102 | + |
|
103 | + if ( trim($value) == 'http://' ) { |
|
104 | + $value = ''; |
|
105 | + } else { |
|
106 | + $value = esc_url_raw( $value ); |
|
107 | + $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
108 | + } |
|
109 | + |
|
110 | + //validate the url format |
|
111 | + if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
112 | 112 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
113 | - } |
|
114 | - } |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | 116 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
117 | - if ( $value == '' || $field->type != 'email' ) { |
|
118 | - return; |
|
119 | - } |
|
117 | + if ( $value == '' || $field->type != 'email' ) { |
|
118 | + return; |
|
119 | + } |
|
120 | 120 | |
121 | - //validate the email format |
|
122 | - if ( ! is_email($value) ) { |
|
121 | + //validate the email format |
|
122 | + if ( ! is_email($value) ) { |
|
123 | 123 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
124 | - } |
|
125 | - } |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | 127 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
128 | 128 | //validate the number format |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | public static function validate_recaptcha( &$errors, $field, $args ) { |
202 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
203 | - return; |
|
204 | - } |
|
202 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
203 | + return; |
|
204 | + } |
|
205 | 205 | |
206 | 206 | $frm_settings = FrmAppHelper::get_settings(); |
207 | 207 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -209,53 +209,53 @@ discard block |
||
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
213 | - // If captcha is missing, check if it was already verified |
|
212 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
213 | + // If captcha is missing, check if it was already verified |
|
214 | 214 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
215 | - // There was no captcha submitted |
|
215 | + // There was no captcha submitted |
|
216 | 216 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
217 | - } |
|
218 | - return; |
|
219 | - } |
|
217 | + } |
|
218 | + return; |
|
219 | + } |
|
220 | 220 | |
221 | - $arg_array = array( |
|
222 | - 'body' => array( |
|
221 | + $arg_array = array( |
|
222 | + 'body' => array( |
|
223 | 223 | 'secret' => $frm_settings->privkey, |
224 | 224 | 'response' => $_POST['g-recaptcha-response'], |
225 | 225 | 'remoteip' => FrmAppHelper::get_ip_address(), |
226 | 226 | ), |
227 | 227 | ); |
228 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
229 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
228 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
229 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
230 | 230 | |
231 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
232 | - // What happens when the CAPTCHA was entered incorrectly |
|
231 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
232 | + // What happens when the CAPTCHA was entered incorrectly |
|
233 | 233 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * check for spam |
|
239 | - * @param boolean $exclude |
|
240 | - * @param array $values |
|
241 | - * @param array $errors by reference |
|
242 | - */ |
|
243 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
244 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
245 | - // only check spam if there are no other errors |
|
246 | - return; |
|
247 | - } |
|
248 | - |
|
249 | - if ( self::is_akismet_spam( $values ) ) { |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * check for spam |
|
239 | + * @param boolean $exclude |
|
240 | + * @param array $values |
|
241 | + * @param array $errors by reference |
|
242 | + */ |
|
243 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
244 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
245 | + // only check spam if there are no other errors |
|
246 | + return; |
|
247 | + } |
|
248 | + |
|
249 | + if ( self::is_akismet_spam( $values ) ) { |
|
250 | 250 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
251 | 251 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
252 | 252 | } |
253 | - } |
|
253 | + } |
|
254 | 254 | |
255 | - if ( self::blacklist_check( $values ) ) { |
|
256 | - $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
257 | - } |
|
258 | - } |
|
255 | + if ( self::blacklist_check( $values ) ) { |
|
256 | + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | 260 | private static function is_akismet_spam( $values ) { |
261 | 261 | global $wpcom_api_key; |
@@ -267,54 +267,54 @@ discard block |
||
267 | 267 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
268 | 268 | } |
269 | 269 | |
270 | - public static function blacklist_check( $values ) { |
|
271 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
272 | - return false; |
|
273 | - } |
|
270 | + public static function blacklist_check( $values ) { |
|
271 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
272 | + return false; |
|
273 | + } |
|
274 | 274 | |
275 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
275 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
276 | 276 | |
277 | - if ( empty( $mod_keys ) ) { |
|
278 | - return false; |
|
279 | - } |
|
277 | + if ( empty( $mod_keys ) ) { |
|
278 | + return false; |
|
279 | + } |
|
280 | 280 | |
281 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
281 | + $content = FrmEntriesHelper::entry_array_to_string($values); |
|
282 | 282 | |
283 | 283 | if ( empty($content) ) { |
284 | - return false; |
|
284 | + return false; |
|
285 | 285 | } |
286 | 286 | |
287 | - $words = explode( "\n", $mod_keys ); |
|
287 | + $words = explode( "\n", $mod_keys ); |
|
288 | 288 | |
289 | - foreach ( (array) $words as $word ) { |
|
290 | - $word = trim( $word ); |
|
289 | + foreach ( (array) $words as $word ) { |
|
290 | + $word = trim( $word ); |
|
291 | 291 | |
292 | - if ( empty($word) ) { |
|
293 | - continue; |
|
294 | - } |
|
292 | + if ( empty($word) ) { |
|
293 | + continue; |
|
294 | + } |
|
295 | 295 | |
296 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
297 | - return true; |
|
298 | - } |
|
299 | - } |
|
296 | + if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
297 | + return true; |
|
298 | + } |
|
299 | + } |
|
300 | 300 | |
301 | - return false; |
|
302 | - } |
|
301 | + return false; |
|
302 | + } |
|
303 | 303 | |
304 | - /** |
|
305 | - * Check entries for spam |
|
306 | - * |
|
307 | - * @return boolean true if is spam |
|
308 | - */ |
|
309 | - public static function akismet( $values ) { |
|
310 | - $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
304 | + /** |
|
305 | + * Check entries for spam |
|
306 | + * |
|
307 | + * @return boolean true if is spam |
|
308 | + */ |
|
309 | + public static function akismet( $values ) { |
|
310 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
311 | 311 | |
312 | 312 | if ( empty( $content ) ) { |
313 | - return false; |
|
313 | + return false; |
|
314 | 314 | } |
315 | 315 | |
316 | - $datas = array(); |
|
317 | - self::parse_akismet_array( $datas, $content ); |
|
316 | + $datas = array(); |
|
317 | + self::parse_akismet_array( $datas, $content ); |
|
318 | 318 | |
319 | 319 | $query_string = ''; |
320 | 320 | foreach ( $datas as $key => $data ) { |
@@ -322,35 +322,35 @@ discard block |
||
322 | 322 | unset( $key, $data ); |
323 | 323 | } |
324 | 324 | |
325 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
325 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
326 | 326 | |
327 | 327 | return ( is_array( $response ) && $response[1] == 'true' ); |
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * @since 2.0 |
|
332 | - * @param string $content |
|
333 | - */ |
|
334 | - private static function parse_akismet_array( &$datas, $content ) { |
|
335 | - $datas['blog'] = FrmAppHelper::site_url(); |
|
336 | - $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * @since 2.0 |
|
332 | + * @param string $content |
|
333 | + */ |
|
334 | + private static function parse_akismet_array( &$datas, $content ) { |
|
335 | + $datas['blog'] = FrmAppHelper::site_url(); |
|
336 | + $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
337 | 337 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
338 | 338 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
339 | - $datas['comment_type'] = 'formidable'; |
|
340 | - $datas['comment_content'] = $content; |
|
339 | + $datas['comment_type'] = 'formidable'; |
|
340 | + $datas['comment_content'] = $content; |
|
341 | 341 | |
342 | - if ( $permalink = get_permalink() ) { |
|
343 | - $datas['permalink'] = $permalink; |
|
344 | - } |
|
342 | + if ( $permalink = get_permalink() ) { |
|
343 | + $datas['permalink'] = $permalink; |
|
344 | + } |
|
345 | 345 | |
346 | - foreach ( $_SERVER as $key => $value ) { |
|
346 | + foreach ( $_SERVER as $key => $value ) { |
|
347 | 347 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
348 | 348 | $datas[ $key ] = wp_strip_all_tags( $value ); |
349 | - } else { |
|
349 | + } else { |
|
350 | 350 | $datas[ $key ] = ''; |
351 | - } |
|
351 | + } |
|
352 | 352 | |
353 | - unset($key, $value); |
|
354 | - } |
|
355 | - } |
|
353 | + unset($key, $value); |
|
354 | + } |
|
355 | + } |
|
356 | 356 | } |
@@ -7,20 +7,20 @@ discard block |
||
7 | 7 | FrmEntry::sanitize_entry_post( $values ); |
8 | 8 | $errors = array(); |
9 | 9 | |
10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
10 | + if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
|
11 | 11 | $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
12 | 12 | return $errors; |
13 | 13 | } |
14 | 14 | |
15 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
|
15 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) { |
|
16 | 16 | $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
17 | 17 | } |
18 | 18 | |
19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
20 | - $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
19 | + if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |
|
20 | + $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
|
21 | 21 | } |
22 | 22 | |
23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
23 | + $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
24 | 24 | // Don't get subfields |
25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | $where['fi.type not'] = $exclude; |
29 | 29 | } |
30 | 30 | |
31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
31 | + $posted_fields = FrmField::getAll( $where, 'field_order' ); |
|
32 | 32 | |
33 | 33 | // Pass exclude value to validate_field function so it can be used for repeating sections |
34 | 34 | $args = array( 'exclude' => $exclude ); |
35 | 35 | |
36 | 36 | foreach ( $posted_fields as $posted_field ) { |
37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
38 | - unset($posted_field); |
|
37 | + self::validate_field( $posted_field, $errors, $values, $args ); |
|
38 | + unset( $posted_field ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // check for spam |
42 | 42 | self::spam_check( $exclude, $values, $errors ); |
43 | 43 | |
44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) ); |
|
45 | 45 | |
46 | 46 | return $errors; |
47 | 47 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | ); |
56 | 56 | $args = wp_parse_args( $args, $defaults ); |
57 | 57 | |
58 | - if ( empty($args['parent_field_id']) ) { |
|
59 | - $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
|
58 | + if ( empty( $args['parent_field_id'] ) ) { |
|
59 | + $value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : ''; |
|
60 | 60 | } else { |
61 | 61 | // value is from a nested form |
62 | 62 | $value = $values; |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | // Check for values in "Other" fields |
66 | 66 | FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
67 | 67 | |
68 | - if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
68 | + if ( isset( $posted_field->field_options['default_blank'] ) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
69 | 69 | $value = ''; |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Check for an array with only one value |
73 | 73 | // Don't reset values in "Other" fields because array keys need to be preserved |
74 | - if ( is_array($value) && count( $value ) == 1 && $args['other'] !== true ) { |
|
75 | - $value = reset($value); |
|
74 | + if ( is_array( $value ) && count( $value ) == 1 && $args['other'] !== true ) { |
|
75 | + $value = reset( $value ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
79 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
79 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
80 | 80 | } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
81 | 81 | $_POST['item_name'] = $value; |
82 | 82 | } |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
89 | 89 | } |
90 | 90 | |
91 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
91 | + FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
|
92 | 92 | |
93 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
93 | + self::validate_recaptcha( $errors, $posted_field, $args ); |
|
94 | 94 | |
95 | - $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
95 | + $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | - if ( trim($value) == 'http://' ) { |
|
103 | + if ( trim( $value ) == 'http://' ) { |
|
104 | 104 | $value = ''; |
105 | 105 | } else { |
106 | 106 | $value = esc_url_raw( $value ); |
107 | - $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
107 | + $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | //validate the url format |
111 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
112 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
111 | + if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) { |
|
112 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | //validate the email format |
122 | - if ( ! is_email($value) ) { |
|
123 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
122 | + if ( ! is_email( $value ) ) { |
|
123 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | - if ( ! is_numeric( $value) ) { |
|
134 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
133 | + if ( ! is_numeric( $value ) ) { |
|
134 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // validate number settings |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) { |
142 | 142 | //minnum maxnum |
143 | 143 | if ( (float) $value < $field->field_options['minnum'] ) { |
144 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' ); |
|
144 | + $errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' ); |
|
145 | 145 | } else if ( (float) $value > $field->field_options['maxnum'] ) { |
146 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' ); |
|
146 | + $errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' ); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $pattern = self::phone_format( $field ); |
158 | 158 | |
159 | 159 | if ( ! preg_match( $pattern, $value ) ) { |
160 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
160 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
212 | + if ( ! isset( $_POST['g-recaptcha-response'] ) ) { |
|
213 | 213 | // If captcha is missing, check if it was already verified |
214 | 214 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
215 | 215 | // There was no captcha submitted |
216 | - $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
|
216 | + $errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' ); |
|
217 | 217 | } |
218 | 218 | return; |
219 | 219 | } |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | ), |
227 | 227 | ); |
228 | 228 | $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
229 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
229 | + $response = json_decode( wp_remote_retrieve_body( $resp ), true ); |
|
230 | 230 | |
231 | 231 | if ( isset( $response['success'] ) && ! $response['success'] ) { |
232 | 232 | // What happens when the CAPTCHA was entered incorrectly |
233 | - $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
233 | + $errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | private static function is_akismet_spam( $values ) { |
261 | 261 | global $wpcom_api_key; |
262 | - return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) ); |
|
262 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | private static function is_akismet_enabled_for_user( $form_id ) { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | public static function blacklist_check( $values ) { |
271 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
271 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
|
272 | 272 | return false; |
273 | 273 | } |
274 | 274 | |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | |
281 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
281 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
282 | 282 | |
283 | - if ( empty($content) ) { |
|
283 | + if ( empty( $content ) ) { |
|
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | foreach ( (array) $words as $word ) { |
290 | 290 | $word = trim( $word ); |
291 | 291 | |
292 | - if ( empty($word) ) { |
|
292 | + if ( empty( $word ) ) { |
|
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | |
296 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
296 | + if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) { |
|
297 | 297 | return true; |
298 | 298 | } |
299 | 299 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | unset( $key, $data ); |
323 | 323 | } |
324 | 324 | |
325 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
325 | + $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
326 | 326 | |
327 | 327 | return ( is_array( $response ) && $response[1] == 'true' ); |
328 | 328 | } |
@@ -345,12 +345,12 @@ discard block |
||
345 | 345 | |
346 | 346 | foreach ( $_SERVER as $key => $value ) { |
347 | 347 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
348 | - $datas[ $key ] = wp_strip_all_tags( $value ); |
|
348 | + $datas[$key] = wp_strip_all_tags( $value ); |
|
349 | 349 | } else { |
350 | - $datas[ $key ] = ''; |
|
350 | + $datas[$key] = ''; |
|
351 | 351 | } |
352 | 352 | |
353 | - unset($key, $value); |
|
353 | + unset( $key, $value ); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | } |