@@ -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 | |
@@ -275,8 +275,8 @@ discard block |
||
| 275 | 275 | return $this->get_pagenum(); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if ( isset( $this->_pagination_args[ $key ] ) ) { |
|
| 279 | - return $this->_pagination_args[ $key ]; |
|
| 278 | + if ( isset( $this->_pagination_args[$key] ) ) { |
|
| 279 | + return $this->_pagination_args[$key]; |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | private function hidden_search_inputs( $param_name ) { |
| 334 | - if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
|
| 335 | - echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
|
| 334 | + if ( ! empty( $_REQUEST[$param_name] ) ) { |
|
| 335 | + echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />'; |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | echo "<ul class='subsubsub'>\n"; |
| 377 | 377 | foreach ( $views as $class => $view ) { |
| 378 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
| 378 | + $views[$class] = "\t<li class='$class'>$view"; |
|
| 379 | 379 | } |
| 380 | 380 | echo implode( " |</li>\n", $views ) . "</li>\n"; |
| 381 | 381 | echo '</ul>'; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | foreach ( $this->_actions as $name => $title ) { |
| 437 | 437 | $class = 'edit' == $name ? ' class="hide-if-no-js"' : ''; |
| 438 | 438 | |
| 439 | - echo "\t<option value='". esc_attr( $name ) ."'$class>$title</option>\n"; |
|
| 439 | + echo "\t<option value='" . esc_attr( $name ) . "'$class>$title</option>\n"; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | echo "</select>\n"; |
@@ -468,8 +468,8 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | private static function get_bulk_action( $action_name ) { |
| 470 | 470 | $action = false; |
| 471 | - if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) { |
|
| 472 | - $action = sanitize_text_field( $_REQUEST[ $action_name ] ); |
|
| 471 | + if ( isset( $_REQUEST[$action_name] ) && -1 != sanitize_text_field( $_REQUEST[$action_name] ) ) { |
|
| 472 | + $action = sanitize_text_field( $_REQUEST[$action_name] ); |
|
| 473 | 473 | } |
| 474 | 474 | return $action; |
| 475 | 475 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | |
| 495 | 495 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 496 | 496 | foreach ( $actions as $action => $link ) { |
| 497 | - ++$i; |
|
| 497 | + ++ $i; |
|
| 498 | 498 | ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
| 499 | 499 | $out .= "<span class='$action'>$link$sep</span>"; |
| 500 | 500 | } |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | |
| 761 | 761 | // If the primary column doesn't exist fall back to the |
| 762 | 762 | // first non-checkbox column. |
| 763 | - if ( ! isset( $columns[ $default ] ) ) { |
|
| 763 | + if ( ! isset( $columns[$default] ) ) { |
|
| 764 | 764 | $default = FrmListHelper::get_default_primary_column_name(); |
| 765 | 765 | } |
| 766 | 766 | |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | */ |
| 775 | 775 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
| 776 | 776 | |
| 777 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
| 777 | + if ( empty( $column ) || ! isset( $columns[$column] ) ) { |
|
| 778 | 778 | $column = $default; |
| 779 | 779 | } |
| 780 | 780 | |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | // In 4.3, we added a fourth argument for primary column. |
| 797 | 797 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
| 798 | 798 | foreach ( $this->_column_headers as $key => $value ) { |
| 799 | - $column_headers[ $key ] = $value; |
|
| 799 | + $column_headers[$key] = $value; |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | return $column_headers; |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $data[1] = false; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - $sortable[ $id ] = $data; |
|
| 832 | + $sortable[$id] = $data; |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | $primary = $this->get_primary_column_name(); |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | static $cb_counter = 1; |
| 885 | 885 | $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
| 886 | 886 | . '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; |
| 887 | - $cb_counter++; |
|
| 887 | + $cb_counter ++; |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | foreach ( $columns as $column_key => $column_display_name ) { |
@@ -904,8 +904,8 @@ discard block |
||
| 904 | 904 | $class[] = 'column-primary'; |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
| 908 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
| 907 | + if ( isset( $sortable[$column_key] ) ) { |
|
| 908 | + list( $orderby, $desc_first ) = $sortable[$column_key]; |
|
| 909 | 909 | |
| 910 | 910 | if ( $current_orderby == $orderby ) { |
| 911 | 911 | $order = 'asc' == $current_order ? 'desc' : 'asc'; |
@@ -520,8 +520,9 @@ |
||
| 520 | 520 | <?php |
| 521 | 521 | foreach ( $this->modes as $mode => $title ) { |
| 522 | 522 | $classes = array( 'view-' . $mode ); |
| 523 | - if ( $current_mode == $mode ) |
|
| 524 | - $classes[] = 'current'; |
|
| 523 | + if ( $current_mode == $mode ) { |
|
| 524 | + $classes[] = 'current'; |
|
| 525 | + } |
|
| 525 | 526 | printf( |
| 526 | 527 | "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
| 527 | 528 | esc_url( add_query_arg( 'mode', $mode ) ), |
@@ -253,6 +253,9 @@ discard block |
||
| 253 | 253 | <?php |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | + /** |
|
| 257 | + * @param string $param_name |
|
| 258 | + */ |
|
| 256 | 259 | private function hidden_search_inputs( $param_name ) { |
| 257 | 260 | if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
| 258 | 261 | echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
@@ -389,6 +392,9 @@ discard block |
||
| 389 | 392 | return $action; |
| 390 | 393 | } |
| 391 | 394 | |
| 395 | + /** |
|
| 396 | + * @param string $action_name |
|
| 397 | + */ |
|
| 392 | 398 | private static function get_bulk_action( $action_name ) { |
| 393 | 399 | $action = false; |
| 394 | 400 | if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) { |
@@ -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 | } |
@@ -272,7 +272,7 @@ |
||
| 272 | 272 | return $message; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - public function manually_queue_update(){ |
|
| 276 | - set_site_transient( 'update_plugins', null ); |
|
| 277 | - } |
|
| 275 | + public function manually_queue_update(){ |
|
| 276 | + set_site_transient( 'update_plugins', null ); |
|
| 277 | + } |
|
| 278 | 278 | } |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function insert_installed_addon( $plugins ) { |
| 41 | - $plugins[ $this->plugin_slug ] = $this; |
|
| 41 | + $plugins[$this->plugin_slug] = $this; |
|
| 42 | 42 | return $plugins; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public static function get_addon( $plugin_slug ) { |
| 46 | 46 | $plugins = apply_filters( 'frm_installed_addons', array() ); |
| 47 | 47 | $plugin = false; |
| 48 | - if ( isset( $plugins[ $plugin_slug ] ) ) { |
|
| 49 | - $plugin = $plugins[ $plugin_slug ]; |
|
| 48 | + if ( isset( $plugins[$plugin_slug] ) ) { |
|
| 49 | + $plugin = $plugins[$plugin_slug]; |
|
| 50 | 50 | } |
| 51 | 51 | return $plugin; |
| 52 | 52 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | if ( empty( $license ) ) { |
| 59 | 59 | add_action( 'after_plugin_row_' . plugin_basename( $this->plugin_file ), array( $this, 'show_license_message' ), 10, 2 ); |
| 60 | 60 | } else { |
| 61 | - if ( ! class_exists('EDD_SL_Plugin_Updater') ) { |
|
| 61 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 62 | 62 | include( dirname( __FILE__ ) . '/EDD_SL_Plugin_Updater.php' ); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -98,32 +98,32 @@ discard block |
||
| 98 | 98 | public function show_license_message( $file, $plugin ) { |
| 99 | 99 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 100 | 100 | echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">'; |
| 101 | - echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
| 101 | + echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
| 102 | 102 | $id = sanitize_title( $plugin['Name'] ); |
| 103 | 103 | echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>'; |
| 104 | 104 | echo '</div></td></tr>'; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function clear_expired_download( $transient ) { |
| 108 | - if ( ! is_object($transient) ) { |
|
| 108 | + if ( ! is_object( $transient ) ) { |
|
| 109 | 109 | return $transient; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | if ( $this->is_current_version( $transient ) ) { |
| 113 | 113 | //make sure it doesn't show there is an update if plugin is up-to-date |
| 114 | - if ( isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
| 115 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
| 114 | + if ( isset( $transient->response[$this->plugin_folder] ) ) { |
|
| 115 | + unset( $transient->response[$this->plugin_folder] ); |
|
| 116 | 116 | } |
| 117 | - } else if ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
| 117 | + } else if ( isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) ) { |
|
| 118 | 118 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $this->license . $this->version ) . '_get_version' ); |
| 119 | 119 | $version_info = get_transient( $cache_key ); |
| 120 | 120 | if ( $version_info !== false ) { |
| 121 | - $transient->response[ $this->plugin_folder ] = $version_info; |
|
| 121 | + $transient->response[$this->plugin_folder] = $version_info; |
|
| 122 | 122 | } else if ( ! $this->has_been_cleared() ) { |
| 123 | 123 | // if the transient has expired, clear the update and trigger it again |
| 124 | 124 | $this->cleared_plugins(); |
| 125 | 125 | $this->manually_queue_update(); |
| 126 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
| 126 | + unset( $transient->response[$this->plugin_folder] ); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | private function is_current_version( $transient ) { |
| 134 | - if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) { |
|
| 134 | + if ( empty( $transient->checked ) || ! isset( $transient->checked[$this->plugin_folder] ) ) { |
|
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | return true; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] == $transient->response[ $this->plugin_folder ]->new_version; |
|
| 143 | + return isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) && $transient->checked[$this->plugin_folder] == $transient->response[$this->plugin_folder]->new_version; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | private function has_been_cleared() { |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | $message = __( 'Your License Key was invalid', 'formidable' ); |
| 252 | 252 | if ( is_wp_error( $resp ) ) { |
| 253 | - $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>'); |
|
| 253 | + $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' ); |
|
| 254 | 254 | if ( is_wp_error( $resp ) ) { |
| 255 | - $message .= ' '. $resp->get_error_message(); |
|
| 255 | + $message .= ' ' . $resp->get_error_message(); |
|
| 256 | 256 | } |
| 257 | 257 | } else if ( $body == 'error' || is_wp_error( $body ) ) { |
| 258 | 258 | $message = __( 'You had an HTTP error connecting to Formidable Pro\'s API', 'formidable' ); |
@@ -265,14 +265,14 @@ discard block |
||
| 265 | 265 | $message = $json_res; |
| 266 | 266 | } |
| 267 | 267 | } else if ( isset( $resp['response'] ) && isset( $resp['response']['code'] ) ) { |
| 268 | - $message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] .' '. $resp['body'] ); |
|
| 268 | + $message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] . ' ' . $resp['body'] ); |
|
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | return $message; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - public function manually_queue_update(){ |
|
| 275 | + public function manually_queue_update() { |
|
| 276 | 276 | set_site_transient( 'update_plugins', null ); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -272,7 +272,7 @@ |
||
| 272 | 272 | return $message; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - public function manually_queue_update(){ |
|
| 275 | + public function manually_queue_update() { |
|
| 276 | 276 | set_site_transient( 'update_plugins', null ); |
| 277 | 277 | } |
| 278 | 278 | } |