@@ -86,7 +86,7 @@ |
||
| 86 | 86 | 'captcha' => 'FrmFieldCaptcha', |
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | - $class = isset( $type_classes[ $field_type ] ) ? $type_classes[ $field_type ] : ''; |
|
| 89 | + $class = isset( $type_classes[$field_type] ) ? $type_classes[$field_type] : ''; |
|
| 90 | 90 | return apply_filters( 'frm_get_field_type_class', $class, $field_type ); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @since 3.0 |
| 56 | 56 | * |
| 57 | 57 | * @param string $field_type |
| 58 | - * @param int|array|object $field |
|
| 58 | + * @param integer $field |
|
| 59 | 59 | * |
| 60 | 60 | * @return stdClass |
| 61 | 61 | */ |
@@ -111,6 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * @since 3.0 |
| 114 | + * @param string $property |
|
| 114 | 115 | */ |
| 115 | 116 | public static function field_has_property( $type, $property ) { |
| 116 | 117 | $field = self::get_field_type( $type ); |
@@ -336,7 +336,7 @@ |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | return self::escape_csv( $line ); |
| 339 | - } |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | 342 | * Escape a " in a csv with another " |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | foreach ( self::$fields as $col ) { |
| 119 | 119 | $field_headings = array(); |
| 120 | 120 | if ( isset( $col->field_options['separate_value'] ) && $col->field_options['separate_value'] && ! in_array( $col->type, array( 'user_id', 'file', 'data', 'date' ), true ) ) { |
| 121 | - $field_headings[ $col->id . '_label' ] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
| 121 | + $field_headings[$col->id . '_label'] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $field_headings[ $col->id ] = strip_tags( $col->name ); |
|
| 124 | + $field_headings[$col->id] = strip_tags( $col->name ); |
|
| 125 | 125 | $field_headings = apply_filters( |
| 126 | 126 | 'frm_csv_field_columns', |
| 127 | 127 | $field_headings, |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if ( self::$comment_count ) { |
| 136 | - for ( $i = 0; $i < self::$comment_count; $i++ ) { |
|
| 137 | - $headings[ 'comment' . $i ] = __( 'Comment', 'formidable' ); |
|
| 138 | - $headings[ 'comment_user_id' . $i ] = __( 'Comment User', 'formidable' ); |
|
| 139 | - $headings[ 'comment_created_at' . $i ] = __( 'Comment Date', 'formidable' ); |
|
| 136 | + for ( $i = 0; $i < self::$comment_count; $i ++ ) { |
|
| 137 | + $headings['comment' . $i] = __( 'Comment', 'formidable' ); |
|
| 138 | + $headings['comment_user_id' . $i] = __( 'Comment User', 'formidable' ); |
|
| 139 | + $headings['comment_created_at' . $i] = __( 'Comment Date', 'formidable' ); |
|
| 140 | 140 | } |
| 141 | 141 | unset( $i ); |
| 142 | 142 | } |
@@ -205,30 +205,30 @@ discard block |
||
| 205 | 205 | continue; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
| 209 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = array(); |
|
| 210 | - } elseif ( ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
| 208 | + if ( ! isset( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
| 209 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = array(); |
|
| 210 | + } elseif ( ! is_array( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
| 211 | 211 | // if the data is here, it should be an array but if this field has collected data |
| 212 | 212 | // both while inside and outside of the repeating section, it's possible this is a string |
| 213 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = (array) $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ]; |
|
| 213 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = (array) $entries[self::$entry->parent_item_id]->metas[$meta_id]; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | //add the repeated values |
| 217 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ][] = $meta_value; |
|
| 217 | + $entries[self::$entry->parent_item_id]->metas[$meta_id][] = $meta_value; |
|
| 218 | 218 | } |
| 219 | - $entries[ self::$entry->parent_item_id ]->metas += self::$entry->metas; |
|
| 219 | + $entries[self::$entry->parent_item_id]->metas += self::$entry->metas; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // add the embedded form id |
| 223 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->embedded_fields ) ) { |
|
| 224 | - $entries[ self::$entry->parent_item_id ]->embedded_fields = array(); |
|
| 223 | + if ( ! isset( $entries[self::$entry->parent_item_id]->embedded_fields ) ) { |
|
| 224 | + $entries[self::$entry->parent_item_id]->embedded_fields = array(); |
|
| 225 | 225 | } |
| 226 | - $entries[ self::$entry->parent_item_id ]->embedded_fields[ self::$entry->id ] = self::$entry->form_id; |
|
| 226 | + $entries[self::$entry->parent_item_id]->embedded_fields[self::$entry->id] = self::$entry->form_id; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | private static function add_field_values_to_csv( &$row ) { |
| 230 | 230 | foreach ( self::$fields as $col ) { |
| 231 | - $field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false; |
|
| 231 | + $field_value = isset( self::$entry->metas[$col->id] ) ? self::$entry->metas[$col->id] : false; |
|
| 232 | 232 | |
| 233 | 233 | $field_value = maybe_unserialize( $field_value ); |
| 234 | 234 | self::add_array_values_to_columns( $row, compact( 'col', 'field_value' ) ); |
@@ -253,14 +253,14 @@ discard block |
||
| 253 | 253 | 'show_icon' => false, |
| 254 | 254 | 'entry_id' => self::$entry->id, |
| 255 | 255 | 'sep' => self::$separator, |
| 256 | - 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[ self::$entry->id ] ) ) ? 'form' . self::$entry->embedded_fields[ self::$entry->id ] : 0, |
|
| 256 | + 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[self::$entry->id] ) ) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0, |
|
| 257 | 257 | ) |
| 258 | 258 | ); |
| 259 | - $row[ $col->id . '_label' ] = $sep_value; |
|
| 259 | + $row[$col->id . '_label'] = $sep_value; |
|
| 260 | 260 | unset( $sep_value ); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - $row[ $col->id ] = $field_value; |
|
| 263 | + $row[$col->id] = $field_value; |
|
| 264 | 264 | |
| 265 | 265 | unset( $col, $field_value ); |
| 266 | 266 | } |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | if ( is_array( $atts['field_value'] ) ) { |
| 274 | 274 | foreach ( $atts['field_value'] as $key => $sub_value ) { |
| 275 | 275 | $column_key = $atts['col']->id . '_' . $key; |
| 276 | - if ( ! is_numeric( $key ) && isset( self::$headings[ $column_key ] ) ) { |
|
| 277 | - $row[ $column_key ] = $sub_value; |
|
| 276 | + if ( ! is_numeric( $key ) && isset( self::$headings[$column_key] ) ) { |
|
| 277 | + $row[$column_key] = $sub_value; |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $sep = ''; |
| 299 | 299 | |
| 300 | 300 | foreach ( self::$headings as $k => $heading ) { |
| 301 | - $row = isset( $rows[ $k ] ) ? $rows[ $k ] : ''; |
|
| 301 | + $row = isset( $rows[$k] ) ? $rows[$k] : ''; |
|
| 302 | 302 | if ( is_array( $row ) ) { |
| 303 | 303 | // implode the repeated field values |
| 304 | 304 | $row = implode( self::$separator, FrmAppHelper::array_flatten( $row, 'reset' ) ); |
@@ -422,6 +422,9 @@ |
||
| 422 | 422 | $reset_fields = true; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | + /** |
|
| 426 | + * @return string |
|
| 427 | + */ |
|
| 425 | 428 | public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
| 426 | 429 | $codes = array( |
| 427 | 430 | 'form_name' => $title, |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public static function add_html_attr( $class, $param, &$add_html ) { |
| 70 | 70 | if ( ! empty( $class ) ) { |
| 71 | - $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
| 71 | + $add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | 'description' => '', |
| 188 | 188 | ); |
| 189 | 189 | foreach ( $defaults as $var => $default ) { |
| 190 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 191 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 190 | + if ( ! isset( $values[$var] ) ) { |
|
| 191 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | 'parent_form_id' => 0, |
| 205 | 205 | ); |
| 206 | 206 | foreach ( $defaults as $var => $default ) { |
| 207 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 208 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 207 | + if ( ! isset( $values[$var] ) ) { |
|
| 208 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | unset( $defaults ); |
@@ -243,16 +243,16 @@ discard block |
||
| 243 | 243 | $defaults = self::get_default_opts(); |
| 244 | 244 | foreach ( $defaults as $var => $default ) { |
| 245 | 245 | if ( is_array( $default ) ) { |
| 246 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 247 | - $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
|
| 246 | + if ( ! isset( $values[$var] ) ) { |
|
| 247 | + $values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array(); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | foreach ( $default as $k => $v ) { |
| 251 | - $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v ); |
|
| 251 | + $values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v ); |
|
| 252 | 252 | |
| 253 | 253 | if ( is_array( $v ) ) { |
| 254 | 254 | foreach ( $v as $k1 => $v1 ) { |
| 255 | - $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 ); |
|
| 255 | + $values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 ); |
|
| 256 | 256 | unset( $k1, $v1 ); |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | unset( $k, $v ); |
| 261 | 261 | } |
| 262 | 262 | } else { |
| 263 | - $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
|
| 263 | + $values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default ); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | unset( $var, $default ); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | public static function fill_form_options( &$options, $values ) { |
| 298 | 298 | $defaults = self::get_default_opts(); |
| 299 | 299 | foreach ( $defaults as $var => $default ) { |
| 300 | - $options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default; |
|
| 300 | + $options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default; |
|
| 301 | 301 | unset( $var, $default ); |
| 302 | 302 | } |
| 303 | 303 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $last_field = false; |
| 377 | 377 | foreach ( $fields as $field ) { |
| 378 | 378 | if ( $prev_order === $field->field_order ) { |
| 379 | - $add_order++; |
|
| 379 | + $add_order ++; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | if ( $add_order ) { |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | } elseif ( isset( $link_details['confirm'] ) ) { |
| 778 | 778 | $link .= ' onclick="return confirm(\'' . esc_attr( $link_details['confirm'] ) . '\')"'; |
| 779 | 779 | } |
| 780 | - $label = ( isset( $link_details[ $length ] ) ? $link_details[ $length ] : $link_details['label'] ); |
|
| 780 | + $label = ( isset( $link_details[$length] ) ? $link_details[$length] : $link_details['label'] ); |
|
| 781 | 781 | $link .= '>' . $label . '</a>'; |
| 782 | 782 | } |
| 783 | 783 | return $link; |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | $status = 'publish'; |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | - $name = $nice_names[ $status ]; |
|
| 948 | + $name = $nice_names[$status]; |
|
| 949 | 949 | |
| 950 | 950 | return $name; |
| 951 | 951 | } |
@@ -16,28 +16,28 @@ discard block |
||
| 16 | 16 | $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) ); |
| 17 | 17 | $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form ); |
| 18 | 18 | |
| 19 | - return $target_url; |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
| 23 | - $defaults = array( |
|
| 24 | - 'blank' => true, |
|
| 25 | - 'field_id' => false, |
|
| 26 | - 'onchange' => false, |
|
| 27 | - 'exclude' => false, |
|
| 28 | - 'class' => '', |
|
| 19 | + return $target_url; |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
| 23 | + $defaults = array( |
|
| 24 | + 'blank' => true, |
|
| 25 | + 'field_id' => false, |
|
| 26 | + 'onchange' => false, |
|
| 27 | + 'exclude' => false, |
|
| 28 | + 'class' => '', |
|
| 29 | 29 | 'inc_children' => 'exclude', |
| 30 | - ); |
|
| 31 | - $args = wp_parse_args( $args, $defaults ); |
|
| 30 | + ); |
|
| 31 | + $args = wp_parse_args( $args, $defaults ); |
|
| 32 | 32 | |
| 33 | - if ( ! $args['field_id'] ) { |
|
| 34 | - $args['field_id'] = $field_name; |
|
| 35 | - } |
|
| 33 | + if ( ! $args['field_id'] ) { |
|
| 34 | + $args['field_id'] = $field_name; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | $query = array(); |
| 38 | - if ( $args['exclude'] ) { |
|
| 38 | + if ( $args['exclude'] ) { |
|
| 39 | 39 | $query['id !'] = $args['exclude']; |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | $where = apply_filters( 'frm_forms_dropdown', $query, $field_name ); |
| 43 | 43 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
| 46 | 46 | self::add_html_attr( $args['class'], 'class', $add_html ); |
| 47 | 47 | |
| 48 | - ?> |
|
| 48 | + ?> |
|
| 49 | 49 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo wp_strip_all_tags( implode( ' ', $add_html ) ); // WPCS: XSS ok. ?>> |
| 50 | 50 | <?php if ( $args['blank'] ) { ?> |
| 51 | 51 | <option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option> |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | <?php } ?> |
| 58 | 58 | </select> |
| 59 | 59 | <?php |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @param string $class |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public static function form_switcher() { |
|
| 75 | + public static function form_switcher() { |
|
| 76 | 76 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 77 | 77 | $forms = FrmForm::get_published_forms( $where ); |
| 78 | 78 | |
@@ -84,32 +84,32 @@ discard block |
||
| 84 | 84 | unset( $args['form'] ); |
| 85 | 85 | } elseif ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) { |
| 86 | 86 | unset( $args['id'] ); |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 90 | 90 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
| 91 | - $args['frm_action'] = 'list'; |
|
| 92 | - $args['form'] = 0; |
|
| 91 | + $args['frm_action'] = 'list'; |
|
| 92 | + $args['form'] = 0; |
|
| 93 | 93 | } elseif ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
| 94 | - $args['frm_action'] = 'edit'; |
|
| 94 | + $args['frm_action'] = 'edit'; |
|
| 95 | 95 | } else if ( isset( $_GET['post'] ) ) { |
| 96 | - $args['form'] = 0; |
|
| 96 | + $args['form'] = 0; |
|
| 97 | 97 | $base = admin_url( 'edit.php?post_type=frm_display' ); |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - ?> |
|
| 100 | + ?> |
|
| 101 | 101 | <li id="frm_bs_dropdown" class="dropdown <?php echo esc_attr( is_rtl() ? 'pull-right' : 'pull-left' ) ?>"> |
| 102 | 102 | <a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php esc_html_e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a> |
| 103 | 103 | <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop"> |
| 104 | 104 | <?php |
| 105 | 105 | foreach ( $forms as $form ) { |
| 106 | 106 | if ( isset( $args['id'] ) ) { |
| 107 | - $args['id'] = $form->id; |
|
| 107 | + $args['id'] = $form->id; |
|
| 108 | 108 | } |
| 109 | - if ( isset( $args['form'] ) ) { |
|
| 110 | - $args['form'] = $form->id; |
|
| 109 | + if ( isset( $args['form'] ) ) { |
|
| 110 | + $args['form'] = $form->id; |
|
| 111 | 111 | } |
| 112 | - ?> |
|
| 112 | + ?> |
|
| 113 | 113 | <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li> |
| 114 | 114 | <?php |
| 115 | 115 | unset( $form ); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | </ul> |
| 119 | 119 | </li> |
| 120 | 120 | <?php |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | public static function get_sortable_classes( $col, $sort_col, $sort_dir ) { |
| 124 | 124 | echo ( $sort_col == $col ) ? 'sorted' : 'sortable'; |
@@ -169,18 +169,18 @@ discard block |
||
| 169 | 169 | return $message; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Used when a form is created |
|
| 174 | - */ |
|
| 175 | - public static function setup_new_vars( $values = array() ) { |
|
| 176 | - global $wpdb; |
|
| 172 | + /** |
|
| 173 | + * Used when a form is created |
|
| 174 | + */ |
|
| 175 | + public static function setup_new_vars( $values = array() ) { |
|
| 176 | + global $wpdb; |
|
| 177 | 177 | |
| 178 | - if ( ! empty( $values ) ) { |
|
| 179 | - $post_values = $values; |
|
| 180 | - } else { |
|
| 181 | - $values = array(); |
|
| 178 | + if ( ! empty( $values ) ) { |
|
| 179 | + $post_values = $values; |
|
| 180 | + } else { |
|
| 181 | + $values = array(); |
|
| 182 | 182 | $post_values = isset( $_POST ) ? $_POST : array(); |
| 183 | - } |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | 185 | $defaults = array( |
| 186 | 186 | 'name' => '', |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | foreach ( $defaults as $var => $default ) { |
| 190 | 190 | if ( ! isset( $values[ $var ] ) ) { |
| 191 | 191 | $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
| 192 | - } |
|
| 193 | - } |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | $values['description'] = FrmAppHelper::use_wpautop( $values['description'] ); |
| 196 | 196 | |
@@ -210,20 +210,20 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | unset( $defaults ); |
| 212 | 212 | |
| 213 | - if ( ! isset( $values['form_key'] ) ) { |
|
| 213 | + if ( ! isset( $values['form_key'] ) ) { |
|
| 214 | 214 | $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' ); |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | 217 | $values = self::fill_default_opts( $values, false, $post_values ); |
| 218 | 218 | $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values ); |
| 219 | 219 | |
| 220 | 220 | return apply_filters( 'frm_setup_new_form_vars', $values ); |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - /** |
|
| 224 | - * Used when editing a form |
|
| 225 | - */ |
|
| 226 | - public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
| 223 | + /** |
|
| 224 | + * Used when editing a form |
|
| 225 | + */ |
|
| 226 | + public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
| 227 | 227 | if ( empty( $post_values ) ) { |
| 228 | 228 | $post_values = stripslashes_deep( $_POST ); |
| 229 | 229 | } |
@@ -231,43 +231,43 @@ discard block |
||
| 231 | 231 | $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key; |
| 232 | 232 | $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template; |
| 233 | 233 | $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template; |
| 234 | - $values['status'] = $record->status; |
|
| 234 | + $values['status'] = $record->status; |
|
| 235 | 235 | |
| 236 | 236 | $values = self::fill_default_opts( $values, $record, $post_values ); |
| 237 | 237 | |
| 238 | 238 | return apply_filters( 'frm_setup_edit_form_vars', $values ); |
| 239 | - } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | public static function fill_default_opts( $values, $record, $post_values ) { |
| 242 | 242 | |
| 243 | - $defaults = self::get_default_opts(); |
|
| 243 | + $defaults = self::get_default_opts(); |
|
| 244 | 244 | foreach ( $defaults as $var => $default ) { |
| 245 | 245 | if ( is_array( $default ) ) { |
| 246 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 246 | + if ( ! isset( $values[ $var ] ) ) { |
|
| 247 | 247 | $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
| 248 | - } |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - foreach ( $default as $k => $v ) { |
|
| 250 | + foreach ( $default as $k => $v ) { |
|
| 251 | 251 | $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v ); |
| 252 | 252 | |
| 253 | - if ( is_array( $v ) ) { |
|
| 254 | - foreach ( $v as $k1 => $v1 ) { |
|
| 253 | + if ( is_array( $v ) ) { |
|
| 254 | + foreach ( $v as $k1 => $v1 ) { |
|
| 255 | 255 | $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 ); |
| 256 | - unset( $k1, $v1 ); |
|
| 257 | - } |
|
| 258 | - } |
|
| 256 | + unset( $k1, $v1 ); |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | unset( $k, $v ); |
| 261 | - } |
|
| 262 | - } else { |
|
| 261 | + } |
|
| 262 | + } else { |
|
| 263 | 263 | $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
| 264 | - } |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | unset( $var, $default ); |
| 267 | - } |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - return $values; |
|
| 270 | - } |
|
| 269 | + return $values; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | 272 | public static function get_default_opts() { |
| 273 | 273 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - /** |
|
| 306 | - * @param string $loc |
|
| 307 | - */ |
|
| 305 | + /** |
|
| 306 | + * @param string $loc |
|
| 307 | + */ |
|
| 308 | 308 | public static function get_default_html( $loc ) { |
| 309 | 309 | if ( $loc == 'submit' ) { |
| 310 | - $draft_link = self::get_draft_link(); |
|
| 311 | - $default_html = <<<SUBMIT_HTML |
|
| 310 | + $draft_link = self::get_draft_link(); |
|
| 311 | + $default_html = <<<SUBMIT_HTML |
|
| 312 | 312 | <div class="frm_submit"> |
| 313 | 313 | [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button] |
| 314 | 314 | <button class="frm_button_submit" type="submit" [button_action]>[button_label]</button> |
@@ -316,22 +316,22 @@ discard block |
||
| 316 | 316 | </div> |
| 317 | 317 | SUBMIT_HTML; |
| 318 | 318 | } else if ( $loc == 'before' ) { |
| 319 | - $default_html = <<<BEFORE_HTML |
|
| 319 | + $default_html = <<<BEFORE_HTML |
|
| 320 | 320 | <legend class="frm_screen_reader">[form_name]</legend> |
| 321 | 321 | [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name] |
| 322 | 322 | [if form_description]<div class="frm_description">[form_description]</div>[/if form_description] |
| 323 | 323 | BEFORE_HTML; |
| 324 | 324 | } else { |
| 325 | - $default_html = ''; |
|
| 326 | - } |
|
| 325 | + $default_html = ''; |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - return $default_html; |
|
| 329 | - } |
|
| 328 | + return $default_html; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - public static function get_draft_link() { |
|
| 332 | - $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
| 333 | - return $link; |
|
| 334 | - } |
|
| 331 | + public static function get_draft_link() { |
|
| 332 | + $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
| 333 | + return $link; |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | 336 | public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) { |
| 337 | 337 | $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values ); |
@@ -358,13 +358,13 @@ discard block |
||
| 358 | 358 | echo $button_parts[1]; // WPCS: XSS ok. |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * Automatically add end section fields if they don't exist (2.0 migration) |
|
| 363 | - * @since 2.0 |
|
| 364 | - * |
|
| 365 | - * @param boolean $reset_fields |
|
| 366 | - */ |
|
| 367 | - public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
| 361 | + /** |
|
| 362 | + * Automatically add end section fields if they don't exist (2.0 migration) |
|
| 363 | + * @since 2.0 |
|
| 364 | + * |
|
| 365 | + * @param boolean $reset_fields |
|
| 366 | + */ |
|
| 367 | + public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
| 368 | 368 | if ( empty( $fields ) ) { |
| 369 | 369 | return; |
| 370 | 370 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $prev_order = false; |
| 375 | 375 | $add_order = 0; |
| 376 | 376 | $last_field = false; |
| 377 | - foreach ( $fields as $field ) { |
|
| 377 | + foreach ( $fields as $field ) { |
|
| 378 | 378 | if ( $prev_order === $field->field_order ) { |
| 379 | 379 | $add_order++; |
| 380 | 380 | } |
@@ -385,48 +385,48 @@ discard block |
||
| 385 | 385 | FrmField::update( $field->id, array( 'field_order' => $field->field_order ) ); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - switch ( $field->type ) { |
|
| 389 | - case 'divider': |
|
| 390 | - // create an end section if open |
|
| 388 | + switch ( $field->type ) { |
|
| 389 | + case 'divider': |
|
| 390 | + // create an end section if open |
|
| 391 | 391 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
| 392 | 392 | |
| 393 | - // mark it open for the next end section |
|
| 394 | - $open = true; |
|
| 393 | + // mark it open for the next end section |
|
| 394 | + $open = true; |
|
| 395 | 395 | break; |
| 396 | - case 'break': |
|
| 396 | + case 'break': |
|
| 397 | 397 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
| 398 | 398 | break; |
| 399 | - case 'end_divider': |
|
| 400 | - if ( ! $open ) { |
|
| 401 | - // the section isn't open, so this is an extra field that needs to be removed |
|
| 402 | - FrmField::destroy( $field->id ); |
|
| 403 | - $reset_fields = true; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - // There is already an end section here, so there is no need to create one |
|
| 407 | - $open = false; |
|
| 408 | - } |
|
| 399 | + case 'end_divider': |
|
| 400 | + if ( ! $open ) { |
|
| 401 | + // the section isn't open, so this is an extra field that needs to be removed |
|
| 402 | + FrmField::destroy( $field->id ); |
|
| 403 | + $reset_fields = true; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + // There is already an end section here, so there is no need to create one |
|
| 407 | + $open = false; |
|
| 408 | + } |
|
| 409 | 409 | $prev_order = $field->field_order; |
| 410 | 410 | |
| 411 | 411 | $last_field = $field; |
| 412 | 412 | unset( $field ); |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | 415 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field ); |
| 416 | - } |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Create end section field if it doesn't exist. This is for migration from < 2.0 |
| 420 | 420 | * Fix any ordering that may be messed up |
| 421 | 421 | */ |
| 422 | 422 | public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) { |
| 423 | - if ( ! $open ) { |
|
| 424 | - return; |
|
| 425 | - } |
|
| 423 | + if ( ! $open ) { |
|
| 424 | + return; |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | 427 | $end_section_values['field_order'] = $field->field_order + 1; |
| 428 | 428 | |
| 429 | - FrmField::create( $end_section_values ); |
|
| 429 | + FrmField::create( $end_section_values ); |
|
| 430 | 430 | |
| 431 | 431 | if ( $move == 'move' ) { |
| 432 | 432 | // bump the order of current field unless we're at the end of the form |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | $add_order += 2; |
| 437 | - $open = false; |
|
| 438 | - $reset_fields = true; |
|
| 439 | - } |
|
| 437 | + $open = false; |
|
| 438 | + $reset_fields = true; |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | 441 | public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
| 442 | 442 | $codes = array( |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html ); |
| 459 | - } |
|
| 459 | + } |
|
| 460 | 460 | |
| 461 | 461 | //replace [form_key] |
| 462 | 462 | $html = str_replace( '[form_key]', $form->form_key, $html ); |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | $submit_label = apply_filters( 'frm_submit_button', $title, $form ); |
| 470 | 470 | $submit_label = esc_attr( do_shortcode( $submit_label ) ); |
| 471 | 471 | $html = str_replace( '[button_label]', $submit_label, $html ); |
| 472 | - } |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | 474 | $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values ); |
| 475 | 475 | |
@@ -485,17 +485,17 @@ discard block |
||
| 485 | 485 | $html = do_shortcode( $html ); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - return $html; |
|
| 489 | - } |
|
| 488 | + return $html; |
|
| 489 | + } |
|
| 490 | 490 | |
| 491 | 491 | public static function submit_button_label( $submit ) { |
| 492 | 492 | if ( ! $submit || empty( $submit ) ) { |
| 493 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 494 | - $submit = $frm_settings->submit_value; |
|
| 495 | - } |
|
| 493 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 494 | + $submit = $frm_settings->submit_value; |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | - return $submit; |
|
| 498 | - } |
|
| 497 | + return $submit; |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | 500 | /** |
| 501 | 501 | * If the Formidable styling isn't being loaded, |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - //If submit button needs to be inline or centered |
|
| 526 | + //If submit button needs to be inline or centered |
|
| 527 | 527 | if ( is_object( $form ) ) { |
| 528 | 528 | $form = $form->options; |
| 529 | 529 | } |
@@ -539,8 +539,8 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | $class = apply_filters( 'frm_add_form_style_class', $class, $style ); |
| 541 | 541 | |
| 542 | - return $class; |
|
| 543 | - } |
|
| 542 | + return $class; |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | 545 | /** |
| 546 | 546 | * Returns appropriate class if form has top labels |
@@ -595,12 +595,12 @@ discard block |
||
| 595 | 595 | return in_array( $label_position, array( 'top', 'inside', 'hidden' ) ); |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - /** |
|
| 599 | - * @param string|boolean $form |
|
| 600 | - * |
|
| 601 | - * @return string |
|
| 602 | - */ |
|
| 603 | - public static function get_form_style( $form ) { |
|
| 598 | + /** |
|
| 599 | + * @param string|boolean $form |
|
| 600 | + * |
|
| 601 | + * @return string |
|
| 602 | + */ |
|
| 603 | + public static function get_form_style( $form ) { |
|
| 604 | 604 | $style = 1; |
| 605 | 605 | if ( empty( $form ) || 'default' == 'form' ) { |
| 606 | 606 | return $style; |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | $style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style; |
| 621 | 621 | |
| 622 | 622 | return $style; |
| 623 | - } |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | 625 | /** |
| 626 | 626 | * Display the validation error messages when an entry is submitted |
@@ -689,8 +689,8 @@ discard block |
||
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | public static function get_scroll_js( $form_id ) { |
| 692 | - echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>'; |
|
| 693 | - } |
|
| 692 | + echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>'; |
|
| 693 | + } |
|
| 694 | 694 | |
| 695 | 695 | /** |
| 696 | 696 | * @since 3.0 |
@@ -745,20 +745,20 @@ discard block |
||
| 745 | 745 | |
| 746 | 746 | public static function edit_form_link( $form_id ) { |
| 747 | 747 | if ( is_object( $form_id ) ) { |
| 748 | - $form = $form_id; |
|
| 749 | - $name = $form->name; |
|
| 750 | - $form_id = $form->id; |
|
| 751 | - } else { |
|
| 748 | + $form = $form_id; |
|
| 749 | + $name = $form->name; |
|
| 750 | + $form_id = $form->id; |
|
| 751 | + } else { |
|
| 752 | 752 | $name = FrmForm::getName( $form_id ); |
| 753 | - } |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | - if ( $form_id ) { |
|
| 755 | + if ( $form_id ) { |
|
| 756 | 756 | $val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>'; |
| 757 | - } else { |
|
| 758 | - $val = ''; |
|
| 759 | - } |
|
| 757 | + } else { |
|
| 758 | + $val = ''; |
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | - return $val; |
|
| 761 | + return $val; |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | public static function delete_trash_link( $id, $status, $length = 'label' ) { |
@@ -939,18 +939,18 @@ discard block |
||
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | public static function status_nice_name( $status ) { |
| 942 | - $nice_names = array( |
|
| 943 | - 'draft' => __( 'Draft', 'formidable' ), |
|
| 944 | - 'trash' => __( 'Trash', 'formidable' ), |
|
| 945 | - 'publish' => __( 'Published', 'formidable' ), |
|
| 946 | - ); |
|
| 942 | + $nice_names = array( |
|
| 943 | + 'draft' => __( 'Draft', 'formidable' ), |
|
| 944 | + 'trash' => __( 'Trash', 'formidable' ), |
|
| 945 | + 'publish' => __( 'Published', 'formidable' ), |
|
| 946 | + ); |
|
| 947 | 947 | |
| 948 | 948 | if ( ! in_array( $status, array_keys( $nice_names ) ) ) { |
| 949 | - $status = 'publish'; |
|
| 950 | - } |
|
| 949 | + $status = 'publish'; |
|
| 950 | + } |
|
| 951 | 951 | |
| 952 | 952 | $name = $nice_names[ $status ]; |
| 953 | 953 | |
| 954 | - return $name; |
|
| 955 | - } |
|
| 954 | + return $name; |
|
| 955 | + } |
|
| 956 | 956 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | <?php |
| 15 | 15 | foreach ( $opts as $opt => $val ) { |
| 16 | 16 | if ( isset( $val['type'] ) && 'text' === $val['type'] ) { |
| 17 | - ?> |
|
| 17 | + ?> |
|
| 18 | 18 | <li> |
| 19 | 19 | <label class="setting" for="frmsc_<?php echo esc_attr( $shortcode . '_' . $opt ) ?>"> |
| 20 | 20 | <span><?php echo esc_html( $val['label'] ) ?></span> |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | </li> |
| 37 | 37 | <?php |
| 38 | 38 | } else { |
| 39 | - ?> |
|
| 39 | + ?> |
|
| 40 | 40 | <li> |
| 41 | 41 | <label class="setting" for="frmsc_<?php echo esc_attr( $shortcode . '_' . $opt ) ?>"> |
| 42 | 42 | <input type="checkbox" id="frmsc_<?php echo esc_attr( $shortcode . '_' . $opt ) ?>" value="<?php echo esc_attr( $val['val'] ) ?>" /> |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | if ( ! isset( $frm_style ) ) { |
| 12 | - $frm_style = new FrmStyle(); |
|
| 12 | + $frm_style = new FrmStyle(); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | $styles = $frm_style->get_all(); |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before{ |
| 126 | - content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ) ?>"; |
|
| 126 | + content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['-'] : $minus_icons[1]['-'] ) ?>"; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_plus_icon:before{ |
| 130 | - content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['+'] : $minus_icons[1]['+'] ) ?>"; |
|
| 130 | + content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['+'] : $minus_icons[1]['+'] ) ?>"; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before, |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | .<?php echo esc_html( $style_class ) ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{ |
| 139 | - content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ) ?>"; |
|
| 139 | + content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['-'] : $arrow_icons[1]['-'] ) ?>"; |
|
| 140 | 140 | color:<?php echo esc_html( $section_color . $important ) ?>; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | .<?php echo esc_html( $style_class ) ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{ |
| 144 | - content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ) ?>"; |
|
| 144 | + content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['+'] : $arrow_icons[1]['+'] ) ?>"; |
|
| 145 | 145 | color:<?php echo esc_html( $section_color . $important ) ?>; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | background-color:<?php echo esc_html( $bg_color . $important ); ?>; |
| 288 | 288 | <?php |
| 289 | 289 | if ( ! empty( $important ) ) { |
| 290 | - echo esc_html( 'background-image:none' . $important . ';' ); |
|
| 290 | + echo esc_html( 'background-image:none' . $important . ';' ); |
|
| 291 | 291 | } |
| 292 | 292 | ?> |
| 293 | 293 | border-color: <?php echo esc_html( $border_color . $important ) ?>; |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | <?php } ?> |
| 523 | 523 | } |
| 524 | 524 | <?php |
| 525 | - } |
|
| 525 | + } |
|
| 526 | 526 | } |
| 527 | 527 | ?> |
| 528 | 528 | |
@@ -246,6 +246,7 @@ |
||
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * @since 3.0 |
| 249 | + * @param stdClass $field_info |
|
| 249 | 250 | */ |
| 250 | 251 | private static function get_classes_for_builder_field( $field, $display, $field_info ) { |
| 251 | 252 | $li_classes = $field_info->form_builder_classes( $display['type'] ); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | ob_start(); |
| 38 | 38 | self::load_single_field( $field, $values ); |
| 39 | - $field_html[ absint( $field->id ) ] = ob_get_contents(); |
|
| 39 | + $field_html[absint( $field->id )] = ob_get_contents(); |
|
| 40 | 40 | ob_end_clean(); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | if ( strpos( $opt, '|' ) !== false ) { |
| 395 | 395 | $vals = explode( '|', $opt ); |
| 396 | 396 | if ( $vals[0] != $vals[1] ) { |
| 397 | - $opts[ $opt_key ] = array( |
|
| 397 | + $opts[$opt_key] = array( |
|
| 398 | 398 | 'label' => trim( $vals[0] ), |
| 399 | 399 | 'value' => trim( $vals[1] ), |
| 400 | 400 | ); |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $other_array = array(); |
| 411 | 411 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 412 | 412 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 413 | - $other_array[ $opt_key ] = $opt; |
|
| 413 | + $other_array[$opt_key] = $opt; |
|
| 414 | 414 | } |
| 415 | 415 | unset( $opt_key, $opt ); |
| 416 | 416 | } |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | 'website' => 'url', |
| 447 | 447 | 'image' => 'url', |
| 448 | 448 | ); |
| 449 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 450 | - $type = $type_switch[ $type ]; |
|
| 449 | + if ( isset( $type_switch[$type] ) ) { |
|
| 450 | + $type = $type_switch[$type]; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | $pro_fields = FrmField::pro_field_selection(); |
@@ -561,11 +561,11 @@ discard block |
||
| 561 | 561 | // include "col" for valid html |
| 562 | 562 | $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
| 563 | 563 | |
| 564 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 564 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 565 | 565 | return; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 568 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 569 | 569 | |
| 570 | 570 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 571 | 571 | } |
@@ -696,10 +696,10 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
| 698 | 698 | $add_html[] = $v; |
| 699 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 700 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
| 699 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 700 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 701 | 701 | } else { |
| 702 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 702 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | unset( $k, $v ); |
@@ -2,25 +2,25 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | 17 | $values = array( |
| 18 | 18 | 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
| 19 | 19 | 'doing_ajax' => true, |
| 20 | 20 | ); |
| 21 | - $field_html = array(); |
|
| 21 | + $field_html = array(); |
|
| 22 | 22 | |
| 23 | - foreach ( $fields as $field ) { |
|
| 23 | + foreach ( $fields as $field ) { |
|
| 24 | 24 | $field = htmlspecialchars_decode( nl2br( $field ) ); |
| 25 | 25 | $field = json_decode( $field ); |
| 26 | 26 | if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) { |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | self::load_single_field( $field, $values ); |
| 40 | 40 | $field_html[ absint( $field->id ) ] = ob_get_contents(); |
| 41 | 41 | ob_end_clean(); |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | echo json_encode( $field_html ); |
| 45 | 45 | |
| 46 | - wp_die(); |
|
| 47 | - } |
|
| 46 | + wp_die(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Create a new field with ajax |
| 51 | 51 | */ |
| 52 | - public static function create() { |
|
| 52 | + public static function create() { |
|
| 53 | 53 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 54 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 54 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 55 | 55 | |
| 56 | 56 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 57 | 57 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
@@ -61,25 +61,25 @@ discard block |
||
| 61 | 61 | // this hook will allow for multiple fields to be added at once |
| 62 | 62 | do_action( 'frm_after_field_created', $field, $form_id ); |
| 63 | 63 | |
| 64 | - wp_die(); |
|
| 65 | - } |
|
| 64 | + wp_die(); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Set up and create a new field |
|
| 69 | - * |
|
| 70 | - * @param string $field_type |
|
| 71 | - * @param integer $form_id |
|
| 72 | - * @return array|bool |
|
| 73 | - */ |
|
| 67 | + /** |
|
| 68 | + * Set up and create a new field |
|
| 69 | + * |
|
| 70 | + * @param string $field_type |
|
| 71 | + * @param integer $form_id |
|
| 72 | + * @return array|bool |
|
| 73 | + */ |
|
| 74 | 74 | public static function include_new_field( $field_type, $form_id ) { |
| 75 | 75 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 76 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 76 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 77 | 77 | |
| 78 | - $field_id = FrmField::create( $field_values ); |
|
| 78 | + $field_id = FrmField::create( $field_values ); |
|
| 79 | 79 | |
| 80 | - if ( ! $field_id ) { |
|
| 81 | - return false; |
|
| 82 | - } |
|
| 80 | + if ( ! $field_id ) { |
|
| 81 | + return false; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | $field = self::get_field_array_from_id( $field_id ); |
| 85 | 85 | |
@@ -95,12 +95,12 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | self::load_single_field( $field, $values, $form_id ); |
| 97 | 97 | |
| 98 | - return $field; |
|
| 99 | - } |
|
| 98 | + return $field; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - public static function update_ajax_option() { |
|
| 101 | + public static function update_ajax_option() { |
|
| 102 | 102 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 103 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 103 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 104 | 104 | |
| 105 | 105 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 106 | 106 | if ( ! $field_id ) { |
@@ -122,20 +122,20 @@ discard block |
||
| 122 | 122 | 'form_id' => $field->form_id, |
| 123 | 123 | ) |
| 124 | 124 | ); |
| 125 | - wp_die(); |
|
| 126 | - } |
|
| 125 | + wp_die(); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - public static function duplicate() { |
|
| 128 | + public static function duplicate() { |
|
| 129 | 129 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 130 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 130 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 131 | 131 | |
| 132 | 132 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 133 | 133 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 134 | 134 | |
| 135 | 135 | $copy_field = FrmField::getOne( $field_id ); |
| 136 | - if ( ! $copy_field ) { |
|
| 136 | + if ( ! $copy_field ) { |
|
| 137 | 137 | wp_die(); |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 141 | 141 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | self::load_single_field( $field_id, $values ); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - wp_die(); |
|
| 155 | - } |
|
| 154 | + wp_die(); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * @since 3.0 |
@@ -223,21 +223,21 @@ discard block |
||
| 223 | 223 | return $li_classes; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public static function destroy() { |
|
| 226 | + public static function destroy() { |
|
| 227 | 227 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 228 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 228 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 229 | 229 | |
| 230 | 230 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 231 | 231 | FrmField::destroy( $field_id ); |
| 232 | - wp_die(); |
|
| 233 | - } |
|
| 232 | + wp_die(); |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - /* Field Options */ |
|
| 235 | + /* Field Options */ |
|
| 236 | 236 | |
| 237 | - //Add Single Option or Other Option |
|
| 238 | - public static function add_option() { |
|
| 237 | + //Add Single Option or Other Option |
|
| 238 | + public static function add_option() { |
|
| 239 | 239 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 240 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 240 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 241 | 241 | |
| 242 | 242 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 243 | 243 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
@@ -262,53 +262,53 @@ discard block |
||
| 262 | 262 | FrmFieldsHelper::show_single_option( $field ); |
| 263 | 263 | |
| 264 | 264 | wp_die(); |
| 265 | - } |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - public static function import_choices() { |
|
| 268 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 267 | + public static function import_choices() { |
|
| 268 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 269 | 269 | |
| 270 | 270 | $field_id = absint( $_REQUEST['field_id'] ); |
| 271 | 271 | |
| 272 | - global $current_screen, $hook_suffix; |
|
| 272 | + global $current_screen, $hook_suffix; |
|
| 273 | 273 | |
| 274 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 275 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 276 | - $hook_suffix = ''; |
|
| 277 | - set_current_screen(); |
|
| 278 | - } |
|
| 274 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 275 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 276 | + $hook_suffix = ''; |
|
| 277 | + set_current_screen(); |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 281 | - register_admin_color_schemes(); |
|
| 282 | - } |
|
| 280 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 281 | + register_admin_color_schemes(); |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | $hook_suffix = ''; |
| 285 | 285 | $admin_body_class = ''; |
| 286 | 286 | |
| 287 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 288 | - $admin_body_class .= ' folded'; |
|
| 289 | - } |
|
| 287 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 288 | + $admin_body_class .= ' folded'; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 292 | - $admin_body_class .= ' admin-bar'; |
|
| 293 | - } |
|
| 291 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 292 | + $admin_body_class .= ' admin-bar'; |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - if ( is_rtl() ) { |
|
| 296 | - $admin_body_class .= ' rtl'; |
|
| 297 | - } |
|
| 295 | + if ( is_rtl() ) { |
|
| 296 | + $admin_body_class .= ' rtl'; |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 300 | - $prepop = array(); |
|
| 299 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 300 | + $prepop = array(); |
|
| 301 | 301 | FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
| 302 | 302 | |
| 303 | 303 | $field = FrmField::getOne( $field_id ); |
| 304 | 304 | |
| 305 | - wp_enqueue_script( 'utils' ); |
|
| 305 | + wp_enqueue_script( 'utils' ); |
|
| 306 | 306 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 307 | - FrmAppHelper::load_admin_wide_js(); |
|
| 307 | + FrmAppHelper::load_admin_wide_js(); |
|
| 308 | 308 | |
| 309 | 309 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 310 | - wp_die(); |
|
| 311 | - } |
|
| 310 | + wp_die(); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | 313 | public static function import_options() { |
| 314 | 314 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | $field = FrmField::getOne( $field_id ); |
| 323 | 323 | |
| 324 | 324 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 325 | - return; |
|
| 326 | - } |
|
| 325 | + return; |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | 328 | $field = FrmFieldsHelper::setup_edit_vars( $field ); |
| 329 | 329 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - //Keep other options after bulk update |
|
| 350 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 351 | - $other_array = array(); |
|
| 352 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 349 | + //Keep other options after bulk update |
|
| 350 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 351 | + $other_array = array(); |
|
| 352 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 353 | 353 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 354 | 354 | $other_array[ $opt_key ] = $opt; |
| 355 | 355 | } |
@@ -360,36 +360,36 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - $field['options'] = $opts; |
|
| 363 | + $field['options'] = $opts; |
|
| 364 | 364 | |
| 365 | 365 | FrmFieldsHelper::show_single_option( $field ); |
| 366 | 366 | |
| 367 | - wp_die(); |
|
| 368 | - } |
|
| 367 | + wp_die(); |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - public static function update_order() { |
|
| 370 | + public static function update_order() { |
|
| 371 | 371 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 372 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 372 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 373 | 373 | |
| 374 | 374 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 375 | 375 | foreach ( (array) $fields as $position => $item ) { |
| 376 | 376 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 377 | 377 | } |
| 378 | - wp_die(); |
|
| 379 | - } |
|
| 378 | + wp_die(); |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | 381 | public static function change_type( $type ) { |
| 382 | - $type_switch = array( |
|
| 383 | - 'scale' => 'radio', |
|
| 382 | + $type_switch = array( |
|
| 383 | + 'scale' => 'radio', |
|
| 384 | 384 | 'star' => 'radio', |
| 385 | - '10radio' => 'radio', |
|
| 386 | - 'rte' => 'textarea', |
|
| 387 | - 'website' => 'url', |
|
| 385 | + '10radio' => 'radio', |
|
| 386 | + 'rte' => 'textarea', |
|
| 387 | + 'website' => 'url', |
|
| 388 | 388 | 'image' => 'url', |
| 389 | - ); |
|
| 390 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 391 | - $type = $type_switch[ $type ]; |
|
| 392 | - } |
|
| 389 | + ); |
|
| 390 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 391 | + $type = $type_switch[ $type ]; |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | 394 | $pro_fields = FrmField::pro_field_selection(); |
| 395 | 395 | $types = array_keys( $pro_fields ); |
@@ -397,8 +397,8 @@ discard block |
||
| 397 | 397 | $type = 'text'; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - return $type; |
|
| 401 | - } |
|
| 400 | + return $type; |
|
| 401 | + } |
|
| 402 | 402 | |
| 403 | 403 | /** |
| 404 | 404 | * @param array $settings |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | return apply_filters( 'frm_display_field_options', $settings ); |
| 416 | - } |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Display the format option |
@@ -425,8 +425,8 @@ discard block |
||
| 425 | 425 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' ); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - public static function input_html( $field, $echo = true ) { |
|
| 429 | - $class = array(); //$field['type']; |
|
| 428 | + public static function input_html( $field, $echo = true ) { |
|
| 429 | + $class = array(); //$field['type']; |
|
| 430 | 430 | self::add_input_classes( $field, $class ); |
| 431 | 431 | |
| 432 | 432 | $add_html = array(); |
@@ -445,85 +445,85 @@ discard block |
||
| 445 | 445 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 446 | 446 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 447 | 447 | |
| 448 | - if ( $echo ) { |
|
| 449 | - echo $add_html; // WPCS: XSS ok. |
|
| 450 | - } |
|
| 448 | + if ( $echo ) { |
|
| 449 | + echo $add_html; // WPCS: XSS ok. |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - return $add_html; |
|
| 453 | - } |
|
| 452 | + return $add_html; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | 455 | private static function add_input_classes( $field, array &$class ) { |
| 456 | 456 | if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
| 457 | 457 | $class[] = $field['input_class']; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 461 | - return; |
|
| 462 | - } |
|
| 460 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 461 | + return; |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | 464 | if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
| 465 | 465 | $class[] = 'auto_width'; |
| 466 | 466 | } |
| 467 | - } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | 469 | private static function add_html_size( $field, array &$add_html ) { |
| 470 | 470 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
| 471 | - return; |
|
| 472 | - } |
|
| 471 | + return; |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | 474 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 475 | - return; |
|
| 476 | - } |
|
| 475 | + return; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | 478 | if ( is_numeric( $field['size'] ) ) { |
| 479 | 479 | $field['size'] .= 'px'; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | $important = apply_filters( 'frm_use_important_width', 1, $field ); |
| 483 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 483 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 484 | 484 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 485 | 485 | |
| 486 | 486 | self::add_html_cols( $field, $add_html ); |
| 487 | - } |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | 489 | private static function add_html_cols( $field, array &$add_html ) { |
| 490 | 490 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 491 | - return; |
|
| 492 | - } |
|
| 491 | + return; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - // convert to cols for textareas |
|
| 495 | - $calc = array( |
|
| 496 | - '' => 9, |
|
| 497 | - 'px' => 9, |
|
| 498 | - 'rem' => 0.444, |
|
| 499 | - 'em' => 0.544, |
|
| 500 | - ); |
|
| 494 | + // convert to cols for textareas |
|
| 495 | + $calc = array( |
|
| 496 | + '' => 9, |
|
| 497 | + 'px' => 9, |
|
| 498 | + 'rem' => 0.444, |
|
| 499 | + 'em' => 0.544, |
|
| 500 | + ); |
|
| 501 | 501 | |
| 502 | 502 | // include "col" for valid html |
| 503 | 503 | $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
| 504 | 504 | |
| 505 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 506 | - return; |
|
| 507 | - } |
|
| 505 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 506 | + return; |
|
| 507 | + } |
|
| 508 | 508 | |
| 509 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 509 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 510 | 510 | |
| 511 | 511 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 512 | - } |
|
| 512 | + } |
|
| 513 | 513 | |
| 514 | 514 | private static function add_html_length( $field, array &$add_html ) { |
| 515 | - // check for max setting and if this field accepts maxlength |
|
| 515 | + // check for max setting and if this field accepts maxlength |
|
| 516 | 516 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
| 517 | - return; |
|
| 518 | - } |
|
| 517 | + return; |
|
| 518 | + } |
|
| 519 | 519 | |
| 520 | 520 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 521 | - // don't load on form builder page |
|
| 522 | - return; |
|
| 523 | - } |
|
| 521 | + // don't load on form builder page |
|
| 522 | + return; |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | 525 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 526 | - } |
|
| 526 | + } |
|
| 527 | 527 | |
| 528 | 528 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 529 | 529 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -632,27 +632,27 @@ discard block |
||
| 632 | 632 | } |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 636 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 637 | - return; |
|
| 638 | - } |
|
| 635 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 636 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 637 | + return; |
|
| 638 | + } |
|
| 639 | 639 | |
| 640 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 641 | - if ( 'opt' === $k ) { |
|
| 642 | - continue; |
|
| 643 | - } |
|
| 640 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 641 | + if ( 'opt' === $k ) { |
|
| 642 | + continue; |
|
| 643 | + } |
|
| 644 | 644 | |
| 645 | 645 | if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
| 646 | - $add_html[] = $v; |
|
| 647 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 646 | + $add_html[] = $v; |
|
| 647 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 648 | 648 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 649 | - } else { |
|
| 649 | + } else { |
|
| 650 | 650 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 651 | - } |
|
| 651 | + } |
|
| 652 | 652 | |
| 653 | 653 | unset( $k, $v ); |
| 654 | - } |
|
| 655 | - } |
|
| 654 | + } |
|
| 655 | + } |
|
| 656 | 656 | |
| 657 | 657 | /** |
| 658 | 658 | * Add pattern attribute |
@@ -676,16 +676,16 @@ discard block |
||
| 676 | 676 | } |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 680 | - if ( is_array( $opt ) ) { |
|
| 681 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 682 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 683 | - } else { |
|
| 684 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 685 | - } |
|
| 686 | - } |
|
| 687 | - return $opt; |
|
| 688 | - } |
|
| 679 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 680 | + if ( is_array( $opt ) ) { |
|
| 681 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 682 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 683 | + } else { |
|
| 684 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 685 | + } |
|
| 686 | + } |
|
| 687 | + return $opt; |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | 690 | public static function check_label( $opt ) { |
| 691 | 691 | if ( is_array( $opt ) ) { |
@@ -149,6 +149,9 @@ |
||
| 149 | 149 | return $name; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | + /** |
|
| 153 | + * @param string $version |
|
| 154 | + */ |
|
| 152 | 155 | private static function get_css_version( $css_key, $version ) { |
| 153 | 156 | if ( 'formidable' == $css_key ) { |
| 154 | 157 | $this_version = get_option( 'frm_last_style_update' ); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $styles = $frm_style->get_all(); |
| 233 | 233 | |
| 234 | 234 | if ( is_numeric( $style ) ) { |
| 235 | - $style = $styles[ $style ]; |
|
| 235 | + $style = $styles[$style]; |
|
| 236 | 236 | } elseif ( 'default' == $style ) { |
| 237 | 237 | $style = $frm_style->get_default_style( $styles ); |
| 238 | 238 | } |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | $forms = FrmForm::get_published_forms(); |
| 270 | 270 | foreach ( $forms as $form ) { |
| 271 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 271 | + if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) { |
|
| 272 | 272 | continue; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 275 | + $form->options['custom_style'] = $_POST['style'][$form->id]; |
|
| 276 | 276 | |
| 277 | 277 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 278 | 278 | unset( $form ); |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | */ |
| 515 | 515 | public static function get_style_val( $val, $form = 'default' ) { |
| 516 | 516 | $style = self::get_form_style( $form ); |
| 517 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
| 518 | - return $style->post_content[ $val ]; |
|
| 517 | + if ( $style && isset( $style->post_content[$val] ) ) { |
|
| 518 | + return $style->post_content[$val]; |
|
| 519 | 519 | } |
| 520 | 520 | } |
| 521 | 521 | |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | } else if ( 'alt_bg_color' == $name ) { |
| 535 | 535 | $setting = 'bg_color_active'; |
| 536 | 536 | } |
| 537 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 537 | + $default_styles[$name] = $style->post_content[$setting]; |
|
| 538 | 538 | unset( $name, $val ); |
| 539 | 539 | } |
| 540 | 540 | |
@@ -568,18 +568,18 @@ discard block |
||
| 568 | 568 | $i = 0; |
| 569 | 569 | $first_open = false; |
| 570 | 570 | do { |
| 571 | - if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
|
| 571 | + if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) { |
|
| 572 | 572 | break; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
| 576 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 577 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 576 | + if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) { |
|
| 577 | + foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { |
|
| 578 | 578 | if ( false == $box || ! $box['title'] ) { |
| 579 | 579 | continue; |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - $i++; |
|
| 582 | + $i ++; |
|
| 583 | 583 | $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
| 584 | 584 | |
| 585 | 585 | if ( ! $first_open && empty( $hidden_class ) ) { |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmStylesController { |
| 4 | - public static $post_type = 'frm_styles'; |
|
| 5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
| 4 | + public static $post_type = 'frm_styles'; |
|
| 5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | 6 | |
| 7 | - public static function load_pro_hooks() { |
|
| 8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | - FrmProStylesController::load_pro_hooks(); |
|
| 10 | - } |
|
| 11 | - } |
|
| 7 | + public static function load_pro_hooks() { |
|
| 8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | + FrmProStylesController::load_pro_hooks(); |
|
| 10 | + } |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public static function register_post_types() { |
|
| 13 | + public static function register_post_types() { |
|
| 14 | 14 | register_post_type( |
| 15 | 15 | self::$post_type, |
| 16 | 16 | array( |
@@ -41,18 +41,18 @@ discard block |
||
| 41 | 41 | ), |
| 42 | 42 | ) |
| 43 | 43 | ); |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public static function menu() { |
|
| 46 | + public static function menu() { |
|
| 47 | 47 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | public static function admin_init() { |
| 51 | 51 | if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) { |
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - self::load_pro_hooks(); |
|
| 55 | + self::load_pro_hooks(); |
|
| 56 | 56 | |
| 57 | 57 | $style_tab = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 58 | 58 | if ( $style_tab == 'manage' || $style_tab == 'custom_css' ) { |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) ); |
| 66 | 66 | |
| 67 | 67 | $style = apply_filters( 'frm_style_head', false ); |
| 68 | - if ( $style ) { |
|
| 68 | + if ( $style ) { |
|
| 69 | 69 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
| 70 | - } |
|
| 71 | - } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | public static function enqueue_css( $register = 'enqueue' ) { |
| 74 | 74 | global $frm_vars; |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public static function load_styler( $style, $message = '' ) { |
| 220 | - global $frm_settings; |
|
| 220 | + global $frm_settings; |
|
| 221 | 221 | |
| 222 | - $frm_style = new FrmStyle(); |
|
| 223 | - $styles = $frm_style->get_all(); |
|
| 222 | + $frm_style = new FrmStyle(); |
|
| 223 | + $styles = $frm_style->get_all(); |
|
| 224 | 224 | |
| 225 | 225 | if ( is_numeric( $style ) ) { |
| 226 | 226 | $style = $styles[ $style ]; |
@@ -228,10 +228,10 @@ discard block |
||
| 228 | 228 | $style = $frm_style->get_default_style( $styles ); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - self::add_meta_boxes(); |
|
| 231 | + self::add_meta_boxes(); |
|
| 232 | 232 | |
| 233 | 233 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
| 234 | - } |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * @param string $message |
@@ -249,31 +249,31 @@ discard block |
||
| 249 | 249 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - private static function manage_styles() { |
|
| 252 | + private static function manage_styles() { |
|
| 253 | 253 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
| 254 | 254 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
| 255 | - return self::manage(); |
|
| 256 | - } |
|
| 255 | + return self::manage(); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - global $wpdb; |
|
| 258 | + global $wpdb; |
|
| 259 | 259 | |
| 260 | 260 | $forms = FrmForm::get_published_forms(); |
| 261 | - foreach ( $forms as $form ) { |
|
| 262 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 263 | - continue; |
|
| 264 | - } |
|
| 261 | + foreach ( $forms as $form ) { |
|
| 262 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 263 | + continue; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 266 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 267 | 267 | |
| 268 | 268 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 269 | 269 | unset( $form ); |
| 270 | - } |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 272 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 273 | 273 | return self::manage( $message, $forms ); |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - public static function custom_css( $message = '', $style = null ) { |
|
| 276 | + public static function custom_css( $message = '', $style = null ) { |
|
| 277 | 277 | if ( function_exists( 'wp_enqueue_code_editor' ) ) { |
| 278 | 278 | $id = 'frm_codemirror_box'; |
| 279 | 279 | $settings = wp_enqueue_code_editor( |
@@ -315,41 +315,41 @@ discard block |
||
| 315 | 315 | return self::custom_css( $message ); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - public static function route() { |
|
| 318 | + public static function route() { |
|
| 319 | 319 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 320 | 320 | |
| 321 | - switch ( $action ) { |
|
| 322 | - case 'edit': |
|
| 323 | - case 'save': |
|
| 324 | - case 'manage': |
|
| 325 | - case 'manage_styles': |
|
| 326 | - case 'custom_css': |
|
| 327 | - case 'save_css': |
|
| 321 | + switch ( $action ) { |
|
| 322 | + case 'edit': |
|
| 323 | + case 'save': |
|
| 324 | + case 'manage': |
|
| 325 | + case 'manage_styles': |
|
| 326 | + case 'custom_css': |
|
| 327 | + case 'save_css': |
|
| 328 | 328 | return self::$action(); |
| 329 | - default: |
|
| 330 | - do_action( 'frm_style_action_route', $action ); |
|
| 331 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 332 | - return; |
|
| 333 | - } |
|
| 329 | + default: |
|
| 330 | + do_action( 'frm_style_action_route', $action ); |
|
| 331 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 332 | + return; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 336 | - return self::$action(); |
|
| 337 | - } |
|
| 335 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 336 | + return self::$action(); |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - return self::edit(); |
|
| 340 | - } |
|
| 341 | - } |
|
| 339 | + return self::edit(); |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - public static function reset_styling() { |
|
| 343 | + public static function reset_styling() { |
|
| 344 | 344 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 345 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 345 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 346 | 346 | |
| 347 | - $frm_style = new FrmStyle(); |
|
| 348 | - $defaults = $frm_style->get_defaults(); |
|
| 347 | + $frm_style = new FrmStyle(); |
|
| 348 | + $defaults = $frm_style->get_defaults(); |
|
| 349 | 349 | |
| 350 | - echo json_encode( $defaults ); |
|
| 351 | - wp_die(); |
|
| 352 | - } |
|
| 350 | + echo json_encode( $defaults ); |
|
| 351 | + wp_die(); |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | public static function change_styling() { |
| 355 | 355 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
@@ -364,21 +364,21 @@ discard block |
||
| 364 | 364 | wp_die(); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - private static function add_meta_boxes() { |
|
| 368 | - |
|
| 369 | - // setup meta boxes |
|
| 370 | - $meta_boxes = array( |
|
| 371 | - 'general' => __( 'General', 'formidable' ), |
|
| 372 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 373 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 374 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 375 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 376 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 377 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 378 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 379 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 380 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 381 | - ); |
|
| 367 | + private static function add_meta_boxes() { |
|
| 368 | + |
|
| 369 | + // setup meta boxes |
|
| 370 | + $meta_boxes = array( |
|
| 371 | + 'general' => __( 'General', 'formidable' ), |
|
| 372 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 373 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 374 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 375 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 376 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 377 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 378 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 379 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 380 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 381 | + ); |
|
| 382 | 382 | |
| 383 | 383 | /** |
| 384 | 384 | * Add custom boxes to the styling settings |
@@ -410,18 +410,18 @@ discard block |
||
| 410 | 410 | $file_name = apply_filters( 'frm_style_settings_' . $sec['args'], $file_name ); |
| 411 | 411 | |
| 412 | 412 | include( $file_name ); |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - public static function load_css() { |
|
| 415 | + public static function load_css() { |
|
| 416 | 416 | header( 'Content-type: text/css' ); |
| 417 | 417 | |
| 418 | - $frm_style = new FrmStyle(); |
|
| 419 | - $defaults = $frm_style->get_defaults(); |
|
| 418 | + $frm_style = new FrmStyle(); |
|
| 419 | + $defaults = $frm_style->get_defaults(); |
|
| 420 | 420 | $style = ''; |
| 421 | 421 | |
| 422 | 422 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
| 423 | - wp_die(); |
|
| 424 | - } |
|
| 423 | + wp_die(); |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | 426 | public static function load_saved_css() { |
| 427 | 427 | $css = get_transient( 'frmpro_css' ); |
@@ -430,49 +430,49 @@ discard block |
||
| 430 | 430 | wp_die(); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - /** |
|
| 434 | - * Check if the Formidable styling should be loaded, |
|
| 435 | - * then enqueue it for the footer |
|
| 436 | - * @since 2.0 |
|
| 437 | - */ |
|
| 438 | - public static function enqueue_style() { |
|
| 439 | - global $frm_vars; |
|
| 440 | - |
|
| 441 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 442 | - // the CSS has already been loaded |
|
| 443 | - return; |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 447 | - if ( $frm_settings->load_style != 'none' ) { |
|
| 448 | - wp_enqueue_style( 'formidable' ); |
|
| 449 | - $frm_vars['css_loaded'] = true; |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - // Get the stylesheets for the form settings page |
|
| 454 | - public static function get_style_opts() { |
|
| 455 | - $frm_style = new FrmStyle(); |
|
| 456 | - $styles = $frm_style->get_all(); |
|
| 457 | - |
|
| 458 | - return $styles; |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - public static function get_form_style( $form = 'default' ) { |
|
| 462 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
| 463 | - |
|
| 464 | - if ( empty( $style ) || 1 == $style ) { |
|
| 465 | - $style = 'default'; |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - $frm_style = new FrmStyle( $style ); |
|
| 469 | - return $frm_style->get_one(); |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - /** |
|
| 473 | - * @param string $class |
|
| 474 | - * @param string $style |
|
| 475 | - */ |
|
| 433 | + /** |
|
| 434 | + * Check if the Formidable styling should be loaded, |
|
| 435 | + * then enqueue it for the footer |
|
| 436 | + * @since 2.0 |
|
| 437 | + */ |
|
| 438 | + public static function enqueue_style() { |
|
| 439 | + global $frm_vars; |
|
| 440 | + |
|
| 441 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 442 | + // the CSS has already been loaded |
|
| 443 | + return; |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 447 | + if ( $frm_settings->load_style != 'none' ) { |
|
| 448 | + wp_enqueue_style( 'formidable' ); |
|
| 449 | + $frm_vars['css_loaded'] = true; |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + // Get the stylesheets for the form settings page |
|
| 454 | + public static function get_style_opts() { |
|
| 455 | + $frm_style = new FrmStyle(); |
|
| 456 | + $styles = $frm_style->get_all(); |
|
| 457 | + |
|
| 458 | + return $styles; |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + public static function get_form_style( $form = 'default' ) { |
|
| 462 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
| 463 | + |
|
| 464 | + if ( empty( $style ) || 1 == $style ) { |
|
| 465 | + $style = 'default'; |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + $frm_style = new FrmStyle( $style ); |
|
| 469 | + return $frm_style->get_one(); |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + /** |
|
| 473 | + * @param string $class |
|
| 474 | + * @param string $style |
|
| 475 | + */ |
|
| 476 | 476 | public static function get_form_style_class( $class, $style ) { |
| 477 | 477 | if ( 1 == $style ) { |
| 478 | 478 | $style = 'default'; |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - /** |
|
| 506 | - * @param string $val |
|
| 507 | - */ |
|
| 505 | + /** |
|
| 506 | + * @param string $val |
|
| 507 | + */ |
|
| 508 | 508 | public static function get_style_val( $val, $form = 'default' ) { |
| 509 | 509 | $style = self::get_form_style( $form ); |
| 510 | 510 | if ( $style && isset( $style->post_content[ $val ] ) ) { |
@@ -514,72 +514,72 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | public static function show_entry_styles( $default_styles ) { |
| 516 | 516 | $frm_style = new FrmStyle( 'default' ); |
| 517 | - $style = $frm_style->get_one(); |
|
| 518 | - |
|
| 519 | - if ( ! $style ) { |
|
| 520 | - return $default_styles; |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - foreach ( $default_styles as $name => $val ) { |
|
| 524 | - $setting = $name; |
|
| 525 | - if ( 'border_width' == $name ) { |
|
| 526 | - $setting = 'field_border_width'; |
|
| 527 | - } else if ( 'alt_bg_color' == $name ) { |
|
| 528 | - $setting = 'bg_color_active'; |
|
| 529 | - } |
|
| 530 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 517 | + $style = $frm_style->get_one(); |
|
| 518 | + |
|
| 519 | + if ( ! $style ) { |
|
| 520 | + return $default_styles; |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + foreach ( $default_styles as $name => $val ) { |
|
| 524 | + $setting = $name; |
|
| 525 | + if ( 'border_width' == $name ) { |
|
| 526 | + $setting = 'field_border_width'; |
|
| 527 | + } else if ( 'alt_bg_color' == $name ) { |
|
| 528 | + $setting = 'bg_color_active'; |
|
| 529 | + } |
|
| 530 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 531 | 531 | unset( $name, $val ); |
| 532 | - } |
|
| 532 | + } |
|
| 533 | 533 | |
| 534 | - return $default_styles; |
|
| 535 | - } |
|
| 534 | + return $default_styles; |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | 537 | public static function &important_style( $important, $field ) { |
| 538 | 538 | $important = self::get_style_val( 'important_style', $field['form_id'] ); |
| 539 | - return $important; |
|
| 540 | - } |
|
| 539 | + return $important; |
|
| 540 | + } |
|
| 541 | 541 | |
| 542 | - /** |
|
| 543 | - * Fallback for WP < 3.6 |
|
| 544 | - */ |
|
| 545 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 546 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 547 | - return do_accordion_sections( $screen, $context, $object ); |
|
| 548 | - } |
|
| 542 | + /** |
|
| 543 | + * Fallback for WP < 3.6 |
|
| 544 | + */ |
|
| 545 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 546 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 547 | + return do_accordion_sections( $screen, $context, $object ); |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | - global $wp_meta_boxes; |
|
| 550 | + global $wp_meta_boxes; |
|
| 551 | 551 | |
| 552 | - $screen = 'formidable_page_formidable-styles'; |
|
| 553 | - $screen = convert_to_screen( $screen ); |
|
| 552 | + $screen = 'formidable_page_formidable-styles'; |
|
| 553 | + $screen = convert_to_screen( $screen ); |
|
| 554 | 554 | |
| 555 | - $page = $screen->id; |
|
| 555 | + $page = $screen->id; |
|
| 556 | 556 | |
| 557 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 558 | - ?> |
|
| 557 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
| 558 | + ?> |
|
| 559 | 559 | <div id="side-sortables" class="accordion-container"> |
| 560 | 560 | <?php |
| 561 | - $i = 0; |
|
| 562 | - $first_open = false; |
|
| 563 | - do { |
|
| 561 | + $i = 0; |
|
| 562 | + $first_open = false; |
|
| 563 | + do { |
|
| 564 | 564 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
| 565 | 565 | break; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 569 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 570 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 571 | - if ( false == $box || ! $box['title'] ) { |
|
| 572 | - continue; |
|
| 568 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 569 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 570 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 571 | + if ( false == $box || ! $box['title'] ) { |
|
| 572 | + continue; |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - $i++; |
|
| 576 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 575 | + $i++; |
|
| 576 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 577 | 577 | |
| 578 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 579 | - $first_open = true; |
|
| 580 | - } |
|
| 578 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 579 | + $first_open = true; |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - ?> |
|
| 582 | + ?> |
|
| 583 | 583 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
| 584 | 584 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ); ?>"><br/></div> |
| 585 | 585 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -590,13 +590,13 @@ discard block |
||
| 590 | 590 | </div><!-- .accordion-section-content --> |
| 591 | 591 | </div><!-- .postbox --> |
| 592 | 592 | <?php |
| 593 | - } |
|
| 594 | - } |
|
| 595 | - } |
|
| 596 | - } while ( 0 ); |
|
| 597 | - ?> |
|
| 593 | + } |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | + } while ( 0 ); |
|
| 597 | + ?> |
|
| 598 | 598 | </div><!-- .accordion-container --> |
| 599 | 599 | <?php |
| 600 | - return $i; |
|
| 601 | - } |
|
| 600 | + return $i; |
|
| 601 | + } |
|
| 602 | 602 | } |
@@ -360,14 +360,14 @@ |
||
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
| 363 | - * Get the fields that should be included in the CSV export |
|
| 364 | - * |
|
| 365 | - * @since 2.0.19 |
|
| 366 | - * |
|
| 367 | - * @param int $form_id |
|
| 368 | - * @param object $form |
|
| 369 | - * @return array $csv_fields |
|
| 370 | - */ |
|
| 363 | + * Get the fields that should be included in the CSV export |
|
| 364 | + * |
|
| 365 | + * @since 2.0.19 |
|
| 366 | + * |
|
| 367 | + * @param int $form_id |
|
| 368 | + * @param object $form |
|
| 369 | + * @return array $csv_fields |
|
| 370 | + */ |
|
| 371 | 371 | private static function get_fields_for_csv_export( $form_id, $form ) { |
| 372 | 372 | $csv_fields = FrmField::get_all_for_form( $form_id, '', 'include', 'include' ); |
| 373 | 373 | $no_export_fields = FrmField::no_save_fields(); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $export_format = apply_filters( 'frm_export_formats', $export_format ); |
| 114 | 114 | |
| 115 | 115 | $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) ); |
| 116 | - if ( 'xml' !== $file_type && isset( $export_format[ $file_type ] ) ) { |
|
| 116 | + if ( 'xml' !== $file_type && isset( $export_format[$file_type] ) ) { |
|
| 117 | 117 | // allow other file types to be imported |
| 118 | 118 | do_action( 'frm_before_import_' . $file_type ); |
| 119 | 119 | return; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | foreach ( $type as $tb_type ) { |
| 206 | 206 | $where = array(); |
| 207 | 207 | $join = ''; |
| 208 | - $table = $tables[ $tb_type ]; |
|
| 208 | + $table = $tables[$tb_type]; |
|
| 209 | 209 | |
| 210 | 210 | $select = $table . '.id'; |
| 211 | 211 | $query_vars = array(); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $table . '.parent_form_id' => $args['ids'], |
| 221 | 221 | ); |
| 222 | 222 | } else { |
| 223 | - $where[ $table . '.status !' ] = 'draft'; |
|
| 223 | + $where[$table . '.status !'] = 'draft'; |
|
| 224 | 224 | } |
| 225 | 225 | break; |
| 226 | 226 | case 'actions': |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | case 'items': |
| 234 | 234 | //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
| 235 | 235 | if ( $args['ids'] ) { |
| 236 | - $where[ $table . '.form_id' ] = $args['ids']; |
|
| 236 | + $where[$table . '.form_id'] = $args['ids']; |
|
| 237 | 237 | } |
| 238 | 238 | break; |
| 239 | 239 | case 'styles': |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 277 | + $records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 278 | 278 | unset( $tb_type ); |
| 279 | 279 | } |
| 280 | 280 | |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $no_export_fields = FrmField::no_save_fields(); |
| 377 | 377 | foreach ( $csv_fields as $k => $f ) { |
| 378 | 378 | if ( in_array( $f->type, $no_export_fields ) ) { |
| 379 | - unset( $csv_fields[ $k ] ); |
|
| 379 | + unset( $csv_fields[$k] ); |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |