@@ -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, |
@@ -19,38 +19,38 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public static function get_direct_link( $key, $form = false ) { |
| 21 | 21 | $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) ); |
| 22 | - $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
| 23 | - |
|
| 24 | - return $target_url; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
| 28 | - $defaults = array( |
|
| 29 | - 'blank' => true, |
|
| 30 | - 'field_id' => false, |
|
| 31 | - 'onchange' => false, |
|
| 32 | - 'exclude' => false, |
|
| 33 | - 'class' => '', |
|
| 22 | + $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
| 23 | + |
|
| 24 | + return $target_url; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
| 28 | + $defaults = array( |
|
| 29 | + 'blank' => true, |
|
| 30 | + 'field_id' => false, |
|
| 31 | + 'onchange' => false, |
|
| 32 | + 'exclude' => false, |
|
| 33 | + 'class' => '', |
|
| 34 | 34 | 'inc_children' => 'exclude', |
| 35 | - ); |
|
| 36 | - $args = wp_parse_args( $args, $defaults ); |
|
| 35 | + ); |
|
| 36 | + $args = wp_parse_args( $args, $defaults ); |
|
| 37 | 37 | |
| 38 | - if ( ! $args['field_id'] ) { |
|
| 39 | - $args['field_id'] = $field_name; |
|
| 40 | - } |
|
| 38 | + if ( ! $args['field_id'] ) { |
|
| 39 | + $args['field_id'] = $field_name; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | $query = array(); |
| 43 | - if ( $args['exclude'] ) { |
|
| 43 | + if ( $args['exclude'] ) { |
|
| 44 | 44 | $query['id !'] = $args['exclude']; |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
| 47 | + $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
| 48 | 48 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
| 49 | 49 | $add_html = array(); |
| 50 | 50 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
| 51 | 51 | self::add_html_attr( $args['class'], 'class', $add_html ); |
| 52 | 52 | |
| 53 | - ?> |
|
| 53 | + ?> |
|
| 54 | 54 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>> |
| 55 | 55 | <?php if ( $args['blank'] ) { ?> |
| 56 | 56 | <option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option> |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | <?php } ?> |
| 65 | 65 | </select> |
| 66 | 66 | <?php |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @param string $class |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public static function form_switcher() { |
|
| 82 | + public static function form_switcher() { |
|
| 83 | 83 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 84 | 84 | $forms = FrmForm::get_published_forms( $where ); |
| 85 | 85 | |
@@ -91,32 +91,32 @@ discard block |
||
| 91 | 91 | unset( $args['form'] ); |
| 92 | 92 | } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) { |
| 93 | 93 | unset( $args['id'] ); |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 97 | 97 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
| 98 | - $args['frm_action'] = 'list'; |
|
| 99 | - $args['form'] = 0; |
|
| 98 | + $args['frm_action'] = 'list'; |
|
| 99 | + $args['form'] = 0; |
|
| 100 | 100 | } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
| 101 | - $args['frm_action'] = 'edit'; |
|
| 101 | + $args['frm_action'] = 'edit'; |
|
| 102 | 102 | } else if ( isset( $_GET['post'] ) ) { |
| 103 | - $args['form'] = 0; |
|
| 104 | - $base = admin_url('edit.php?post_type=frm_display'); |
|
| 105 | - } |
|
| 103 | + $args['form'] = 0; |
|
| 104 | + $base = admin_url('edit.php?post_type=frm_display'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - ?> |
|
| 107 | + ?> |
|
| 108 | 108 | <li class="dropdown last" id="frm_bs_dropdown"> |
| 109 | 109 | <a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php esc_html_e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a> |
| 110 | 110 | <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop"> |
| 111 | 111 | <?php |
| 112 | 112 | foreach ( $forms as $form ) { |
| 113 | 113 | if ( isset( $args['id'] ) ) { |
| 114 | - $args['id'] = $form->id; |
|
| 114 | + $args['id'] = $form->id; |
|
| 115 | 115 | } |
| 116 | - if ( isset( $args['form'] ) ) { |
|
| 117 | - $args['form'] = $form->id; |
|
| 116 | + if ( isset( $args['form'] ) ) { |
|
| 117 | + $args['form'] = $form->id; |
|
| 118 | 118 | } |
| 119 | - ?> |
|
| 119 | + ?> |
|
| 120 | 120 | <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> |
| 121 | 121 | <?php |
| 122 | 122 | unset( $form ); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | </ul> |
| 126 | 126 | </li> |
| 127 | 127 | <?php |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | public static function get_sortable_classes( $col, $sort_col, $sort_dir ) { |
| 131 | 131 | echo ( $sort_col == $col ) ? 'sorted' : 'sortable'; |
@@ -154,18 +154,18 @@ discard block |
||
| 154 | 154 | return $message; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - /** |
|
| 158 | - * Used when a form is created |
|
| 159 | - */ |
|
| 160 | - public static function setup_new_vars( $values = array() ) { |
|
| 161 | - global $wpdb; |
|
| 157 | + /** |
|
| 158 | + * Used when a form is created |
|
| 159 | + */ |
|
| 160 | + public static function setup_new_vars( $values = array() ) { |
|
| 161 | + global $wpdb; |
|
| 162 | 162 | |
| 163 | - if ( ! empty( $values ) ) { |
|
| 164 | - $post_values = $values; |
|
| 165 | - } else { |
|
| 166 | - $values = array(); |
|
| 167 | - $post_values = isset($_POST) ? $_POST : array(); |
|
| 168 | - } |
|
| 163 | + if ( ! empty( $values ) ) { |
|
| 164 | + $post_values = $values; |
|
| 165 | + } else { |
|
| 166 | + $values = array(); |
|
| 167 | + $post_values = isset($_POST) ? $_POST : array(); |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | 170 | $defaults = array( |
| 171 | 171 | 'name' => '', |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | foreach ( $defaults as $var => $default ) { |
| 175 | 175 | if ( ! isset( $values[ $var ] ) ) { |
| 176 | 176 | $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
| 177 | - } |
|
| 178 | - } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
| 180 | + $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
| 181 | 181 | |
| 182 | 182 | $defaults = array( |
| 183 | 183 | 'form_id' => '', |
@@ -195,64 +195,64 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | unset( $defaults ); |
| 197 | 197 | |
| 198 | - if ( ! isset( $values['form_key'] ) ) { |
|
| 198 | + if ( ! isset( $values['form_key'] ) ) { |
|
| 199 | 199 | $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' ); |
| 200 | - } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | $values = self::fill_default_opts( $values, false, $post_values ); |
| 203 | 203 | $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values ); |
| 204 | 204 | |
| 205 | - return apply_filters('frm_setup_new_form_vars', $values); |
|
| 206 | - } |
|
| 205 | + return apply_filters('frm_setup_new_form_vars', $values); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - /** |
|
| 209 | - * Used when editing a form |
|
| 210 | - */ |
|
| 211 | - public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
| 208 | + /** |
|
| 209 | + * Used when editing a form |
|
| 210 | + */ |
|
| 211 | + public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
| 212 | 212 | if ( empty( $post_values ) ) { |
| 213 | 213 | $post_values = stripslashes_deep( $_POST ); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
| 217 | - $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
| 218 | - $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
| 219 | - $values['status'] = $record->status; |
|
| 216 | + $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
| 217 | + $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
| 218 | + $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
| 219 | + $values['status'] = $record->status; |
|
| 220 | 220 | |
| 221 | - $values = self::fill_default_opts($values, $record, $post_values); |
|
| 221 | + $values = self::fill_default_opts($values, $record, $post_values); |
|
| 222 | 222 | |
| 223 | - return apply_filters('frm_setup_edit_form_vars', $values); |
|
| 224 | - } |
|
| 223 | + return apply_filters('frm_setup_edit_form_vars', $values); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | 226 | public static function fill_default_opts( $values, $record, $post_values ) { |
| 227 | 227 | |
| 228 | - $defaults = self::get_default_opts(); |
|
| 228 | + $defaults = self::get_default_opts(); |
|
| 229 | 229 | foreach ( $defaults as $var => $default ) { |
| 230 | - if ( is_array($default) ) { |
|
| 231 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 230 | + if ( is_array($default) ) { |
|
| 231 | + if ( ! isset( $values[ $var ] ) ) { |
|
| 232 | 232 | $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - foreach ( $default as $k => $v ) { |
|
| 235 | + foreach ( $default as $k => $v ) { |
|
| 236 | 236 | $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 ); |
| 237 | 237 | |
| 238 | - if ( is_array( $v ) ) { |
|
| 239 | - foreach ( $v as $k1 => $v1 ) { |
|
| 238 | + if ( is_array( $v ) ) { |
|
| 239 | + foreach ( $v as $k1 => $v1 ) { |
|
| 240 | 240 | $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 ); |
| 241 | - unset( $k1, $v1 ); |
|
| 242 | - } |
|
| 243 | - } |
|
| 241 | + unset( $k1, $v1 ); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - unset($k, $v); |
|
| 246 | - } |
|
| 247 | - } else { |
|
| 245 | + unset($k, $v); |
|
| 246 | + } |
|
| 247 | + } else { |
|
| 248 | 248 | $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
| 249 | - } |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - unset($var, $default); |
|
| 252 | - } |
|
| 251 | + unset($var, $default); |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - return $values; |
|
| 255 | - } |
|
| 254 | + return $values; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | 257 | public static function get_default_opts() { |
| 258 | 258 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -286,13 +286,13 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - /** |
|
| 290 | - * @param string $loc |
|
| 291 | - */ |
|
| 289 | + /** |
|
| 290 | + * @param string $loc |
|
| 291 | + */ |
|
| 292 | 292 | public static function get_default_html( $loc ) { |
| 293 | 293 | if ( $loc == 'submit' ) { |
| 294 | - $draft_link = self::get_draft_link(); |
|
| 295 | - $default_html = <<<SUBMIT_HTML |
|
| 294 | + $draft_link = self::get_draft_link(); |
|
| 295 | + $default_html = <<<SUBMIT_HTML |
|
| 296 | 296 | <div class="frm_submit"> |
| 297 | 297 | [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button] |
| 298 | 298 | <button class="frm_button_submit" type="submit" [button_action]>[button_label]</button> |
@@ -300,22 +300,22 @@ discard block |
||
| 300 | 300 | </div> |
| 301 | 301 | SUBMIT_HTML; |
| 302 | 302 | } else if ( $loc == 'before' ) { |
| 303 | - $default_html = <<<BEFORE_HTML |
|
| 303 | + $default_html = <<<BEFORE_HTML |
|
| 304 | 304 | <legend class="frm_hidden">[form_name]</legend> |
| 305 | 305 | [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name] |
| 306 | 306 | [if form_description]<div class="frm_description">[form_description]</div>[/if form_description] |
| 307 | 307 | BEFORE_HTML; |
| 308 | 308 | } else { |
| 309 | - $default_html = ''; |
|
| 310 | - } |
|
| 309 | + $default_html = ''; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - return $default_html; |
|
| 313 | - } |
|
| 312 | + return $default_html; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - public static function get_draft_link() { |
|
| 316 | - $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
| 317 | - return $link; |
|
| 318 | - } |
|
| 315 | + public static function get_draft_link() { |
|
| 316 | + $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
| 317 | + return $link; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) { |
| 321 | 321 | $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values ); |
@@ -342,13 +342,13 @@ discard block |
||
| 342 | 342 | echo $button_parts[1]; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - /** |
|
| 346 | - * Automatically add end section fields if they don't exist (2.0 migration) |
|
| 347 | - * @since 2.0 |
|
| 348 | - * |
|
| 349 | - * @param boolean $reset_fields |
|
| 350 | - */ |
|
| 351 | - public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
| 345 | + /** |
|
| 346 | + * Automatically add end section fields if they don't exist (2.0 migration) |
|
| 347 | + * @since 2.0 |
|
| 348 | + * |
|
| 349 | + * @param boolean $reset_fields |
|
| 350 | + */ |
|
| 351 | + public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
| 352 | 352 | if ( empty( $fields ) ) { |
| 353 | 353 | return; |
| 354 | 354 | } |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | $prev_order = false; |
| 359 | 359 | $add_order = 0; |
| 360 | 360 | $last_field = false; |
| 361 | - foreach ( $fields as $field ) { |
|
| 361 | + foreach ( $fields as $field ) { |
|
| 362 | 362 | if ( $prev_order === $field->field_order ) { |
| 363 | 363 | $add_order++; |
| 364 | 364 | } |
@@ -369,48 +369,48 @@ discard block |
||
| 369 | 369 | FrmField::update( $field->id, array( 'field_order' => $field->field_order ) ); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - switch ( $field->type ) { |
|
| 373 | - case 'divider': |
|
| 374 | - // create an end section if open |
|
| 372 | + switch ( $field->type ) { |
|
| 373 | + case 'divider': |
|
| 374 | + // create an end section if open |
|
| 375 | 375 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
| 376 | 376 | |
| 377 | - // mark it open for the next end section |
|
| 378 | - $open = true; |
|
| 377 | + // mark it open for the next end section |
|
| 378 | + $open = true; |
|
| 379 | 379 | break; |
| 380 | - case 'break': |
|
| 380 | + case 'break': |
|
| 381 | 381 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
| 382 | 382 | break; |
| 383 | - case 'end_divider': |
|
| 384 | - if ( ! $open ) { |
|
| 385 | - // the section isn't open, so this is an extra field that needs to be removed |
|
| 386 | - FrmField::destroy( $field->id ); |
|
| 387 | - $reset_fields = true; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - // There is already an end section here, so there is no need to create one |
|
| 391 | - $open = false; |
|
| 392 | - } |
|
| 383 | + case 'end_divider': |
|
| 384 | + if ( ! $open ) { |
|
| 385 | + // the section isn't open, so this is an extra field that needs to be removed |
|
| 386 | + FrmField::destroy( $field->id ); |
|
| 387 | + $reset_fields = true; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + // There is already an end section here, so there is no need to create one |
|
| 391 | + $open = false; |
|
| 392 | + } |
|
| 393 | 393 | $prev_order = $field->field_order; |
| 394 | 394 | |
| 395 | 395 | $last_field = $field; |
| 396 | 396 | unset( $field ); |
| 397 | - } |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | 399 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field ); |
| 400 | - } |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | 402 | /** |
| 403 | 403 | * Create end section field if it doesn't exist. This is for migration from < 2.0 |
| 404 | 404 | * Fix any ordering that may be messed up |
| 405 | 405 | */ |
| 406 | 406 | public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) { |
| 407 | - if ( ! $open ) { |
|
| 408 | - return; |
|
| 409 | - } |
|
| 407 | + if ( ! $open ) { |
|
| 408 | + return; |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | 411 | $end_section_values['field_order'] = $field->field_order + 1; |
| 412 | 412 | |
| 413 | - FrmField::create( $end_section_values ); |
|
| 413 | + FrmField::create( $end_section_values ); |
|
| 414 | 414 | |
| 415 | 415 | if ( $move == 'move' ) { |
| 416 | 416 | // bump the order of current field unless we're at the end of the form |
@@ -418,9 +418,9 @@ discard block |
||
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | $add_order += 2; |
| 421 | - $open = false; |
|
| 422 | - $reset_fields = true; |
|
| 423 | - } |
|
| 421 | + $open = false; |
|
| 422 | + $reset_fields = true; |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | 425 | public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
| 426 | 426 | $codes = array( |
@@ -429,33 +429,33 @@ discard block |
||
| 429 | 429 | 'entry_key' => true, |
| 430 | 430 | ); |
| 431 | 431 | foreach ( $codes as $code => $show ) { |
| 432 | - if ( $code == 'form_name' ) { |
|
| 433 | - $replace_with = $form->name; |
|
| 434 | - } else if ( $code == 'form_description' ) { |
|
| 435 | - $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
| 436 | - } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
| 437 | - $replace_with = FrmAppHelper::simple_get( 'entry' ); |
|
| 438 | - } else { |
|
| 439 | - $replace_with = ''; |
|
| 440 | - } |
|
| 432 | + if ( $code == 'form_name' ) { |
|
| 433 | + $replace_with = $form->name; |
|
| 434 | + } else if ( $code == 'form_description' ) { |
|
| 435 | + $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
| 436 | + } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
| 437 | + $replace_with = FrmAppHelper::simple_get( 'entry' ); |
|
| 438 | + } else { |
|
| 439 | + $replace_with = ''; |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
| 443 | - } |
|
| 442 | + FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - //replace [form_key] |
|
| 446 | - $html = str_replace('[form_key]', $form->form_key, $html); |
|
| 445 | + //replace [form_key] |
|
| 446 | + $html = str_replace('[form_key]', $form->form_key, $html); |
|
| 447 | 447 | |
| 448 | - //replace [frmurl] |
|
| 449 | - $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
| 448 | + //replace [frmurl] |
|
| 449 | + $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
| 450 | 450 | |
| 451 | 451 | if ( strpos( $html, '[button_label]' ) ) { |
| 452 | 452 | add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 ); |
| 453 | 453 | $submit_label = apply_filters( 'frm_submit_button', $title, $form ); |
| 454 | 454 | $submit_label = esc_attr( do_shortcode( $submit_label ) ); |
| 455 | 455 | $html = str_replace( '[button_label]', $submit_label, $html ); |
| 456 | - } |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | - $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
| 458 | + $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
| 459 | 459 | |
| 460 | 460 | if ( strpos( $html, '[if back_button]' ) ) { |
| 461 | 461 | $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html ); |
@@ -469,17 +469,17 @@ discard block |
||
| 469 | 469 | $html = do_shortcode( $html ); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - return $html; |
|
| 473 | - } |
|
| 472 | + return $html; |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | 475 | public static function submit_button_label( $submit ) { |
| 476 | - if ( ! $submit || empty($submit) ) { |
|
| 477 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 478 | - $submit = $frm_settings->submit_value; |
|
| 479 | - } |
|
| 476 | + if ( ! $submit || empty($submit) ) { |
|
| 477 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 478 | + $submit = $frm_settings->submit_value; |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - return $submit; |
|
| 482 | - } |
|
| 481 | + return $submit; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | 484 | /** |
| 485 | 485 | * If the Formidable styling isn't being loaded, |
@@ -496,19 +496,19 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | public static function get_form_style_class( $form = false ) { |
| 499 | - $style = self::get_form_style($form); |
|
| 500 | - $class = ' with_frm_style'; |
|
| 501 | - |
|
| 502 | - if ( empty($style) ) { |
|
| 503 | - if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
| 504 | - return $class; |
|
| 505 | - } else { |
|
| 506 | - return; |
|
| 507 | - } |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - //If submit button needs to be inline or centered |
|
| 511 | - if ( is_object($form) ) { |
|
| 499 | + $style = self::get_form_style($form); |
|
| 500 | + $class = ' with_frm_style'; |
|
| 501 | + |
|
| 502 | + if ( empty($style) ) { |
|
| 503 | + if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
| 504 | + return $class; |
|
| 505 | + } else { |
|
| 506 | + return; |
|
| 507 | + } |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + //If submit button needs to be inline or centered |
|
| 511 | + if ( is_object($form) ) { |
|
| 512 | 512 | $form = $form->options; |
| 513 | 513 | } |
| 514 | 514 | |
@@ -520,17 +520,17 @@ discard block |
||
| 520 | 520 | $class .= ' frm_center_submit'; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
| 523 | + $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
| 524 | 524 | |
| 525 | - return $class; |
|
| 526 | - } |
|
| 525 | + return $class; |
|
| 526 | + } |
|
| 527 | 527 | |
| 528 | - /** |
|
| 529 | - * @param string|boolean $form |
|
| 530 | - * |
|
| 531 | - * @return string |
|
| 532 | - */ |
|
| 533 | - public static function get_form_style( $form ) { |
|
| 528 | + /** |
|
| 529 | + * @param string|boolean $form |
|
| 530 | + * |
|
| 531 | + * @return string |
|
| 532 | + */ |
|
| 533 | + public static function get_form_style( $form ) { |
|
| 534 | 534 | $style = 1; |
| 535 | 535 | if ( empty( $form ) || 'default' == 'form' ) { |
| 536 | 536 | return $style; |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | $style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style; |
| 551 | 551 | |
| 552 | 552 | return $style; |
| 553 | - } |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | 555 | /** |
| 556 | 556 | * Display the validation error messages when an entry is submitted |
@@ -616,74 +616,74 @@ discard block |
||
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | public static function get_scroll_js( $form_id ) { |
| 619 | - echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>'; |
|
| 620 | - } |
|
| 619 | + echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>'; |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | public static function edit_form_link( $form_id ) { |
| 623 | - if ( is_object($form_id) ) { |
|
| 624 | - $form = $form_id; |
|
| 625 | - $name = $form->name; |
|
| 626 | - $form_id = $form->id; |
|
| 627 | - } else { |
|
| 628 | - $name = FrmForm::getName($form_id); |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - if ( $form_id ) { |
|
| 623 | + if ( is_object($form_id) ) { |
|
| 624 | + $form = $form_id; |
|
| 625 | + $name = $form->name; |
|
| 626 | + $form_id = $form->id; |
|
| 627 | + } else { |
|
| 628 | + $name = FrmForm::getName($form_id); |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + if ( $form_id ) { |
|
| 632 | 632 | $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>'; |
| 633 | - } else { |
|
| 634 | - $val = ''; |
|
| 635 | - } |
|
| 633 | + } else { |
|
| 634 | + $val = ''; |
|
| 635 | + } |
|
| 636 | 636 | |
| 637 | - return $val; |
|
| 637 | + return $val; |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | public static function delete_trash_link( $id, $status, $length = 'long' ) { |
| 641 | - $link = ''; |
|
| 642 | - $labels = array( |
|
| 643 | - 'restore' => array( |
|
| 644 | - 'long' => __( 'Restore from Trash', 'formidable' ), |
|
| 645 | - 'short' => __( 'Restore', 'formidable' ), |
|
| 646 | - ), |
|
| 647 | - 'trash' => array( |
|
| 648 | - 'long' => __( 'Move to Trash', 'formidable' ), |
|
| 649 | - 'short' => __( 'Trash', 'formidable' ), |
|
| 650 | - ), |
|
| 651 | - 'delete' => array( |
|
| 652 | - 'long' => __( 'Delete Permanently', 'formidable' ), |
|
| 653 | - 'short' => __( 'Delete', 'formidable' ), |
|
| 654 | - ), |
|
| 655 | - ); |
|
| 641 | + $link = ''; |
|
| 642 | + $labels = array( |
|
| 643 | + 'restore' => array( |
|
| 644 | + 'long' => __( 'Restore from Trash', 'formidable' ), |
|
| 645 | + 'short' => __( 'Restore', 'formidable' ), |
|
| 646 | + ), |
|
| 647 | + 'trash' => array( |
|
| 648 | + 'long' => __( 'Move to Trash', 'formidable' ), |
|
| 649 | + 'short' => __( 'Trash', 'formidable' ), |
|
| 650 | + ), |
|
| 651 | + 'delete' => array( |
|
| 652 | + 'long' => __( 'Delete Permanently', 'formidable' ), |
|
| 653 | + 'short' => __( 'Delete', 'formidable' ), |
|
| 654 | + ), |
|
| 655 | + ); |
|
| 656 | 656 | |
| 657 | 657 | $current_page = FrmAppHelper::get_simple_request( array( 'param' => 'form_type' ) ); |
| 658 | 658 | $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id; |
| 659 | - if ( 'trash' == $status ) { |
|
| 659 | + if ( 'trash' == $status ) { |
|
| 660 | 660 | $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>'; |
| 661 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
| 662 | - if ( EMPTY_TRASH_DAYS ) { |
|
| 661 | + } else if ( current_user_can('frm_delete_forms') ) { |
|
| 662 | + if ( EMPTY_TRASH_DAYS ) { |
|
| 663 | 663 | $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>'; |
| 664 | - } else { |
|
| 664 | + } else { |
|
| 665 | 665 | $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>'; |
| 666 | - } |
|
| 667 | - } |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | - return $link; |
|
| 670 | - } |
|
| 669 | + return $link; |
|
| 670 | + } |
|
| 671 | 671 | |
| 672 | 672 | public static function status_nice_name( $status ) { |
| 673 | - $nice_names = array( |
|
| 674 | - 'draft' => __( 'Draft', 'formidable' ), |
|
| 675 | - 'trash' => __( 'Trash', 'formidable' ), |
|
| 676 | - 'publish' => __( 'Published', 'formidable' ), |
|
| 677 | - ); |
|
| 673 | + $nice_names = array( |
|
| 674 | + 'draft' => __( 'Draft', 'formidable' ), |
|
| 675 | + 'trash' => __( 'Trash', 'formidable' ), |
|
| 676 | + 'publish' => __( 'Published', 'formidable' ), |
|
| 677 | + ); |
|
| 678 | 678 | |
| 679 | - if ( ! in_array($status, array_keys($nice_names)) ) { |
|
| 680 | - $status = 'publish'; |
|
| 681 | - } |
|
| 679 | + if ( ! in_array($status, array_keys($nice_names)) ) { |
|
| 680 | + $status = 'publish'; |
|
| 681 | + } |
|
| 682 | 682 | |
| 683 | 683 | $name = $nice_names[ $status ]; |
| 684 | 684 | |
| 685 | - return $name; |
|
| 686 | - } |
|
| 685 | + return $name; |
|
| 686 | + } |
|
| 687 | 687 | |
| 688 | 688 | public static function get_params() { |
| 689 | 689 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' ); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public static function get_direct_link( $key, $form = false ) { |
| 21 | 21 | $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) ); |
| 22 | - $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
| 22 | + $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form ); |
|
| 23 | 23 | |
| 24 | 24 | return $target_url; |
| 25 | 25 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $query['id !'] = $args['exclude']; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
| 47 | + $where = apply_filters( 'frm_forms_dropdown', $query, $field_name ); |
|
| 48 | 48 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
| 49 | 49 | $add_html = array(); |
| 50 | 50 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | <?php foreach ( $forms as $form ) { ?> |
| 59 | 59 | <option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>> |
| 60 | 60 | <?php |
| 61 | - echo esc_html( '' === $form->name ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $form->name, 50 ) . ( $form->parent_form_id ? __( ' (child)', 'formidable' ) : '' ) ) ; |
|
| 61 | + echo esc_html( '' === $form->name ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $form->name, 50 ) . ( $form->parent_form_id ? __( ' (child)', 'formidable' ) : '' ) ); |
|
| 62 | 62 | ?> |
| 63 | 63 | </option> |
| 64 | 64 | <?php } ?> |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public static function add_html_attr( $class, $param, &$add_html ) { |
| 77 | 77 | if ( ! empty( $class ) ) { |
| 78 | - $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
| 78 | + $add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) { |
| 91 | 91 | unset( $args['form'] ); |
| 92 | - } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) { |
|
| 92 | + } else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) { |
|
| 93 | 93 | unset( $args['id'] ); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
| 98 | 98 | $args['frm_action'] = 'list'; |
| 99 | 99 | $args['form'] = 0; |
| 100 | - } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
|
| 100 | + } else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
|
| 101 | 101 | $args['frm_action'] = 'edit'; |
| 102 | 102 | } else if ( isset( $_GET['post'] ) ) { |
| 103 | 103 | $args['form'] = 0; |
| 104 | - $base = admin_url('edit.php?post_type=frm_display'); |
|
| 104 | + $base = admin_url( 'edit.php?post_type=frm_display' ); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | ?> |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $post_values = $values; |
| 165 | 165 | } else { |
| 166 | 166 | $values = array(); |
| 167 | - $post_values = isset($_POST) ? $_POST : array(); |
|
| 167 | + $post_values = isset( $_POST ) ? $_POST : array(); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $defaults = array( |
@@ -172,12 +172,12 @@ discard block |
||
| 172 | 172 | 'description' => '', |
| 173 | 173 | ); |
| 174 | 174 | foreach ( $defaults as $var => $default ) { |
| 175 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 176 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 175 | + if ( ! isset( $values[$var] ) ) { |
|
| 176 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
| 180 | + $values['description'] = FrmAppHelper::use_wpautop( $values['description'] ); |
|
| 181 | 181 | |
| 182 | 182 | $defaults = array( |
| 183 | 183 | 'form_id' => '', |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | 'parent_form_id' => 0, |
| 190 | 190 | ); |
| 191 | 191 | foreach ( $defaults as $var => $default ) { |
| 192 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 193 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 192 | + if ( ! isset( $values[$var] ) ) { |
|
| 193 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | unset( $defaults ); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $values = self::fill_default_opts( $values, false, $post_values ); |
| 203 | 203 | $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values ); |
| 204 | 204 | |
| 205 | - return apply_filters('frm_setup_new_form_vars', $values); |
|
| 205 | + return apply_filters( 'frm_setup_new_form_vars', $values ); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -213,42 +213,42 @@ discard block |
||
| 213 | 213 | $post_values = stripslashes_deep( $_POST ); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
| 217 | - $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
| 218 | - $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
| 216 | + $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key; |
|
| 217 | + $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template; |
|
| 218 | + $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template; |
|
| 219 | 219 | $values['status'] = $record->status; |
| 220 | 220 | |
| 221 | - $values = self::fill_default_opts($values, $record, $post_values); |
|
| 221 | + $values = self::fill_default_opts( $values, $record, $post_values ); |
|
| 222 | 222 | |
| 223 | - return apply_filters('frm_setup_edit_form_vars', $values); |
|
| 223 | + return apply_filters( 'frm_setup_edit_form_vars', $values ); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | public static function fill_default_opts( $values, $record, $post_values ) { |
| 227 | 227 | |
| 228 | 228 | $defaults = self::get_default_opts(); |
| 229 | 229 | foreach ( $defaults as $var => $default ) { |
| 230 | - if ( is_array($default) ) { |
|
| 231 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 232 | - $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
|
| 230 | + if ( is_array( $default ) ) { |
|
| 231 | + if ( ! isset( $values[$var] ) ) { |
|
| 232 | + $values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array(); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | foreach ( $default as $k => $v ) { |
| 236 | - $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 ); |
|
| 236 | + $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 ); |
|
| 237 | 237 | |
| 238 | 238 | if ( is_array( $v ) ) { |
| 239 | 239 | foreach ( $v as $k1 => $v1 ) { |
| 240 | - $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 ); |
|
| 240 | + $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 ); |
|
| 241 | 241 | unset( $k1, $v1 ); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - unset($k, $v); |
|
| 245 | + unset( $k, $v ); |
|
| 246 | 246 | } |
| 247 | 247 | } else { |
| 248 | - $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
|
| 248 | + $values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default ); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - unset($var, $default); |
|
| 251 | + unset( $var, $default ); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $values; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | public static function fill_form_options( &$options, $values ) { |
| 282 | 282 | $defaults = self::get_default_opts(); |
| 283 | 283 | foreach ( $defaults as $var => $default ) { |
| 284 | - $options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default; |
|
| 284 | + $options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default; |
|
| 285 | 285 | unset( $var, $default ); |
| 286 | 286 | } |
| 287 | 287 | } |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $last_field = false; |
| 361 | 361 | foreach ( $fields as $field ) { |
| 362 | 362 | if ( $prev_order === $field->field_order ) { |
| 363 | - $add_order++; |
|
| 363 | + $add_order ++; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | if ( $add_order ) { |
@@ -432,21 +432,21 @@ discard block |
||
| 432 | 432 | if ( $code == 'form_name' ) { |
| 433 | 433 | $replace_with = $form->name; |
| 434 | 434 | } else if ( $code == 'form_description' ) { |
| 435 | - $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
| 436 | - } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
| 435 | + $replace_with = FrmAppHelper::use_wpautop( $form->description ); |
|
| 436 | + } else if ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) { |
|
| 437 | 437 | $replace_with = FrmAppHelper::simple_get( 'entry' ); |
| 438 | 438 | } else { |
| 439 | 439 | $replace_with = ''; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
| 442 | + FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html ); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | //replace [form_key] |
| 446 | - $html = str_replace('[form_key]', $form->form_key, $html); |
|
| 446 | + $html = str_replace( '[form_key]', $form->form_key, $html ); |
|
| 447 | 447 | |
| 448 | 448 | //replace [frmurl] |
| 449 | - $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
| 449 | + $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html ); |
|
| 450 | 450 | |
| 451 | 451 | if ( strpos( $html, '[button_label]' ) ) { |
| 452 | 452 | add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 ); |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $html = str_replace( '[button_label]', $submit_label, $html ); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
| 458 | + $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values ); |
|
| 459 | 459 | |
| 460 | 460 | if ( strpos( $html, '[if back_button]' ) ) { |
| 461 | 461 | $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html ); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | public static function submit_button_label( $submit ) { |
| 476 | - if ( ! $submit || empty($submit) ) { |
|
| 476 | + if ( ! $submit || empty( $submit ) ) { |
|
| 477 | 477 | $frm_settings = FrmAppHelper::get_settings(); |
| 478 | 478 | $submit = $frm_settings->submit_value; |
| 479 | 479 | } |
@@ -496,11 +496,11 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | public static function get_form_style_class( $form = false ) { |
| 499 | - $style = self::get_form_style($form); |
|
| 499 | + $style = self::get_form_style( $form ); |
|
| 500 | 500 | $class = ' with_frm_style'; |
| 501 | 501 | |
| 502 | - if ( empty($style) ) { |
|
| 503 | - if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
| 502 | + if ( empty( $style ) ) { |
|
| 503 | + if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) { |
|
| 504 | 504 | return $class; |
| 505 | 505 | } else { |
| 506 | 506 | return; |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | //If submit button needs to be inline or centered |
| 511 | - if ( is_object($form) ) { |
|
| 511 | + if ( is_object( $form ) ) { |
|
| 512 | 512 | $form = $form->options; |
| 513 | 513 | } |
| 514 | 514 | |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | $class .= ' frm_center_submit'; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
| 523 | + $class = apply_filters( 'frm_add_form_style_class', $class, $style ); |
|
| 524 | 524 | |
| 525 | 525 | return $class; |
| 526 | 526 | } |
@@ -620,12 +620,12 @@ discard block |
||
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | public static function edit_form_link( $form_id ) { |
| 623 | - if ( is_object($form_id) ) { |
|
| 623 | + if ( is_object( $form_id ) ) { |
|
| 624 | 624 | $form = $form_id; |
| 625 | 625 | $name = $form->name; |
| 626 | 626 | $form_id = $form->id; |
| 627 | 627 | } else { |
| 628 | - $name = FrmForm::getName($form_id); |
|
| 628 | + $name = FrmForm::getName( $form_id ); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | if ( $form_id ) { |
@@ -657,12 +657,12 @@ discard block |
||
| 657 | 657 | $current_page = FrmAppHelper::get_simple_request( array( 'param' => 'form_type' ) ); |
| 658 | 658 | $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id; |
| 659 | 659 | if ( 'trash' == $status ) { |
| 660 | - $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>'; |
|
| 661 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
| 660 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][$length] . '</a>'; |
|
| 661 | + } else if ( current_user_can( 'frm_delete_forms' ) ) { |
|
| 662 | 662 | if ( EMPTY_TRASH_DAYS ) { |
| 663 | - $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>'; |
|
| 663 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][$length] . '</a>'; |
|
| 664 | 664 | } else { |
| 665 | - $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>'; |
|
| 665 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][$length] . '</a>'; |
|
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | 668 | |
@@ -676,11 +676,11 @@ discard block |
||
| 676 | 676 | 'publish' => __( 'Published', 'formidable' ), |
| 677 | 677 | ); |
| 678 | 678 | |
| 679 | - if ( ! in_array($status, array_keys($nice_names)) ) { |
|
| 679 | + if ( ! in_array( $status, array_keys( $nice_names ) ) ) { |
|
| 680 | 680 | $status = 'publish'; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - $name = $nice_names[ $status ]; |
|
| 683 | + $name = $nice_names[$status]; |
|
| 684 | 684 | |
| 685 | 685 | return $name; |
| 686 | 686 | } |
@@ -259,6 +259,9 @@ discard block |
||
| 259 | 259 | <?php |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | + /** |
|
| 263 | + * @param string $param_name |
|
| 264 | + */ |
|
| 262 | 265 | private function hidden_search_inputs( $param_name ) { |
| 263 | 266 | if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
| 264 | 267 | echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
@@ -397,6 +400,9 @@ discard block |
||
| 397 | 400 | return $action; |
| 398 | 401 | } |
| 399 | 402 | |
| 403 | + /** |
|
| 404 | + * @param string $action_name |
|
| 405 | + */ |
|
| 400 | 406 | private static function get_bulk_action( $action_name ) { |
| 401 | 407 | $action = false; |
| 402 | 408 | $action_param = self::get_param( array( |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | protected $modes = array(); |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | - * |
|
| 71 | - * @var array |
|
| 72 | - */ |
|
| 73 | - protected $params; |
|
| 70 | + * |
|
| 71 | + * @var array |
|
| 72 | + */ |
|
| 73 | + protected $params; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Stores the value returned by ->get_column_info() |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', 'row_actions', 'view_switcher', 'get_items_per_page', 'pagination', 'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav', 'single_row_columns' ); |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * Construct the table object |
|
| 88 | - */ |
|
| 87 | + * Construct the table object |
|
| 88 | + */ |
|
| 89 | 89 | public function __construct( $args ) { |
| 90 | - $args = wp_parse_args( $args, array( |
|
| 90 | + $args = wp_parse_args( $args, array( |
|
| 91 | 91 | 'params' => array(), |
| 92 | 92 | 'plural' => '', |
| 93 | 93 | 'singular' => '', |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class FrmField { |
| 7 | 7 | |
| 8 | - static $use_cache = true; |
|
| 8 | + static $use_cache = true; |
|
| 9 | 9 | static $transient_size = 200; |
| 10 | 10 | |
| 11 | 11 | public static function field_selection() { |
@@ -52,39 +52,39 @@ discard block |
||
| 52 | 52 | )); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public static function create( $values, $return = true ) { |
|
| 56 | - global $wpdb, $frm_duplicate_ids; |
|
| 55 | + public static function create( $values, $return = true ) { |
|
| 56 | + global $wpdb, $frm_duplicate_ids; |
|
| 57 | 57 | |
| 58 | - $new_values = array(); |
|
| 59 | - $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
| 58 | + $new_values = array(); |
|
| 59 | + $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
| 60 | 60 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 61 | 61 | |
| 62 | 62 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 63 | 63 | $new_values[ $col ] = $values[ $col ]; |
| 64 | - } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $new_values['options'] = $values['options']; |
|
| 66 | + $new_values['options'] = $values['options']; |
|
| 67 | 67 | |
| 68 | - $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
| 69 | - $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
| 70 | - $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
| 71 | - $new_values['field_options'] = $values['field_options']; |
|
| 72 | - $new_values['created_at'] = current_time('mysql', 1); |
|
| 68 | + $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
| 69 | + $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
| 70 | + $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
| 71 | + $new_values['field_options'] = $values['field_options']; |
|
| 72 | + $new_values['created_at'] = current_time('mysql', 1); |
|
| 73 | 73 | |
| 74 | 74 | if ( isset( $values['id'] ) ) { |
| 75 | 75 | $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
| 76 | - $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
| 77 | - } |
|
| 76 | + $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | foreach ( $new_values as $k => $v ) { |
| 80 | - if ( is_array( $v ) ) { |
|
| 80 | + if ( is_array( $v ) ) { |
|
| 81 | 81 | $new_values[ $k ] = serialize( $v ); |
| 82 | 82 | } |
| 83 | - unset( $k, $v ); |
|
| 84 | - } |
|
| 83 | + unset( $k, $v ); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - //if(isset($values['id']) and is_numeric($values['id'])) |
|
| 87 | - // $new_values['id'] = $values['id']; |
|
| 86 | + //if(isset($values['id']) and is_numeric($values['id'])) |
|
| 87 | + // $new_values['id'] = $values['id']; |
|
| 88 | 88 | |
| 89 | 89 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
| 90 | 90 | $new_id = 0; |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | } else { |
| 106 | 106 | return false; |
| 107 | 107 | } |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
| 111 | - global $frm_duplicate_ids; |
|
| 110 | + public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
| 111 | + global $frm_duplicate_ids; |
|
| 112 | 112 | |
| 113 | 113 | $where = array( |
| 114 | 114 | array( |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | ); |
| 120 | 120 | $fields = self::getAll( $where, 'field_order', '', $blog_id ); |
| 121 | 121 | |
| 122 | - foreach ( (array) $fields as $field ) { |
|
| 122 | + foreach ( (array) $fields as $field ) { |
|
| 123 | 123 | $new_key = $copy_keys ? $field->field_key : ''; |
| 124 | - if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
| 125 | - $new_key = rtrim($new_key, 2); |
|
| 126 | - } |
|
| 124 | + if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
| 125 | + $new_key = rtrim($new_key, 2); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - $values = array(); |
|
| 129 | - FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
| 128 | + $values = array(); |
|
| 129 | + FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
| 130 | 130 | |
| 131 | 131 | // If this is a repeating section, create new form |
| 132 | 132 | if ( self::is_repeating_field( $field ) ) { |
@@ -148,16 +148,16 @@ discard block |
||
| 148 | 148 | $values['form_id'] = $new_repeat_form_id; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $values = apply_filters('frm_duplicated_field', $values); |
|
| 152 | - $new_id = self::create($values); |
|
| 153 | - $frm_duplicate_ids[ $field->id ] = $new_id; |
|
| 154 | - $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
| 155 | - unset($field); |
|
| 156 | - } |
|
| 157 | - } |
|
| 151 | + $values = apply_filters('frm_duplicated_field', $values); |
|
| 152 | + $new_id = self::create($values); |
|
| 153 | + $frm_duplicate_ids[ $field->id ] = $new_id; |
|
| 154 | + $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
| 155 | + unset($field); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | public static function update( $id, $values ) { |
| 160 | - global $wpdb; |
|
| 160 | + global $wpdb; |
|
| 161 | 161 | |
| 162 | 162 | $id = absint( $id ); |
| 163 | 163 | |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ( isset($values['required']) ) { |
|
| 169 | - $values['required'] = (int) $values['required']; |
|
| 170 | - } |
|
| 168 | + if ( isset($values['required']) ) { |
|
| 169 | + $values['required'] = (int) $values['required']; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | 172 | self::preserve_format_option_backslashes( $values ); |
| 173 | 173 | |
@@ -189,41 +189,41 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) ); |
| 191 | 191 | |
| 192 | - $form_id = 0; |
|
| 192 | + $form_id = 0; |
|
| 193 | 193 | if ( isset( $values['form_id'] ) ) { |
| 194 | - $form_id = absint( $values['form_id'] ); |
|
| 194 | + $form_id = absint( $values['form_id'] ); |
|
| 195 | 195 | } else { |
| 196 | - $field = self::getOne($id); |
|
| 197 | - if ( $field ) { |
|
| 198 | - $form_id = $field->form_id; |
|
| 199 | - } |
|
| 200 | - unset($field); |
|
| 201 | - } |
|
| 202 | - unset($values); |
|
| 196 | + $field = self::getOne($id); |
|
| 197 | + if ( $field ) { |
|
| 198 | + $form_id = $field->form_id; |
|
| 199 | + } |
|
| 200 | + unset($field); |
|
| 201 | + } |
|
| 202 | + unset($values); |
|
| 203 | 203 | |
| 204 | 204 | if ( $query_results ) { |
| 205 | - wp_cache_delete( $id, 'frm_field' ); |
|
| 206 | - if ( $form_id ) { |
|
| 207 | - self::delete_form_transient( $form_id ); |
|
| 208 | - } |
|
| 209 | - } |
|
| 205 | + wp_cache_delete( $id, 'frm_field' ); |
|
| 206 | + if ( $form_id ) { |
|
| 207 | + self::delete_form_transient( $form_id ); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - return $query_results; |
|
| 212 | - } |
|
| 211 | + return $query_results; |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | - * Keep backslashes in the phone format option |
|
| 216 | - * |
|
| 217 | - * @since 2.0.8 |
|
| 218 | - * @param $values array - pass by reference |
|
| 219 | - */ |
|
| 215 | + * Keep backslashes in the phone format option |
|
| 216 | + * |
|
| 217 | + * @since 2.0.8 |
|
| 218 | + * @param $values array - pass by reference |
|
| 219 | + */ |
|
| 220 | 220 | private static function preserve_format_option_backslashes( &$values ) { |
| 221 | 221 | if ( isset( $values['field_options']['format'] ) ) { |
| 222 | 222 | $values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] ); |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public static function destroy( $id ) { |
|
| 226 | + public static function destroy( $id ) { |
|
| 227 | 227 | global $wpdb; |
| 228 | 228 | |
| 229 | 229 | do_action( 'frm_before_destroy_field', $id ); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) ); |
| 240 | 240 | return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) ); |
| 241 | - } |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | 243 | public static function delete_form_transient( $form_id ) { |
| 244 | 244 | $form_id = absint( $form_id ); |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | FrmDb::cache_delete_group( 'frm_field' ); |
| 254 | 254 | |
| 255 | - $form = FrmForm::getOne($form_id); |
|
| 256 | - if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) { |
|
| 257 | - self::delete_form_transient( $form->parent_form_id ); |
|
| 258 | - } |
|
| 259 | - } |
|
| 255 | + $form = FrmForm::getOne($form_id); |
|
| 256 | + if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) { |
|
| 257 | + self::delete_form_transient( $form->parent_form_id ); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | 262 | * If $field is numeric, get the field object |
@@ -272,83 +272,83 @@ discard block |
||
| 272 | 272 | return null; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - global $wpdb; |
|
| 275 | + global $wpdb; |
|
| 276 | 276 | |
| 277 | - $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
| 277 | + $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
| 278 | 278 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); |
| 279 | 279 | |
| 280 | - $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
| 280 | + $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
| 281 | 281 | |
| 282 | - if ( empty($results) ) { |
|
| 283 | - return $results; |
|
| 284 | - } |
|
| 282 | + if ( empty($results) ) { |
|
| 283 | + return $results; |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - if ( is_numeric($id) ) { |
|
| 286 | + if ( is_numeric($id) ) { |
|
| 287 | 287 | FrmDb::set_cache( $results->field_key, $results, 'frm_field' ); |
| 288 | - } else if ( $results ) { |
|
| 288 | + } else if ( $results ) { |
|
| 289 | 289 | FrmDb::set_cache( $results->id, $results, 'frm_field' ); |
| 290 | - } |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | 292 | self::prepare_options( $results ); |
| 293 | 293 | |
| 294 | - return stripslashes_deep($results); |
|
| 295 | - } |
|
| 294 | + return stripslashes_deep($results); |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - /** |
|
| 298 | - * Get the field type by key or id |
|
| 299 | - * @param int|string The field id or key |
|
| 297 | + /** |
|
| 298 | + * Get the field type by key or id |
|
| 299 | + * @param int|string The field id or key |
|
| 300 | 300 | * @param mixed $col The name of the column in the fields database table |
| 301 | - */ |
|
| 302 | - public static function get_type( $id, $col = 'type' ) { |
|
| 303 | - $field = FrmDb::check_cache( $id, 'frm_field' ); |
|
| 304 | - if ( $field ) { |
|
| 305 | - $type = $field->{$col}; |
|
| 306 | - } else { |
|
| 301 | + */ |
|
| 302 | + public static function get_type( $id, $col = 'type' ) { |
|
| 303 | + $field = FrmDb::check_cache( $id, 'frm_field' ); |
|
| 304 | + if ( $field ) { |
|
| 305 | + $type = $field->{$col}; |
|
| 306 | + } else { |
|
| 307 | 307 | $where = array( |
| 308 | 308 | 'or' => 1, |
| 309 | 309 | 'id' => $id, |
| 310 | 310 | 'field_key' => $id, |
| 311 | 311 | ); |
| 312 | 312 | $type = FrmDb::get_var( 'frm_fields', $where, $col ); |
| 313 | - } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - return $type; |
|
| 316 | - } |
|
| 315 | + return $type; |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | 318 | public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) { |
| 319 | - if ( ! $form_id ) { |
|
| 320 | - return array(); |
|
| 321 | - } |
|
| 319 | + if ( ! $form_id ) { |
|
| 320 | + return array(); |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | 323 | $results = self::get_fields_from_transients( $form_id, array( |
| 324 | 324 | 'inc_embed' => $inc_sub, |
| 325 | 325 | 'inc_repeat' => $inc_sub, |
| 326 | 326 | ) ); |
| 327 | 327 | if ( ! empty( $results ) ) { |
| 328 | - $fields = array(); |
|
| 329 | - $count = 0; |
|
| 330 | - foreach ( $results as $result ) { |
|
| 331 | - if ( $type != $result->type ) { |
|
| 332 | - continue; |
|
| 333 | - } |
|
| 328 | + $fields = array(); |
|
| 329 | + $count = 0; |
|
| 330 | + foreach ( $results as $result ) { |
|
| 331 | + if ( $type != $result->type ) { |
|
| 332 | + continue; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | 335 | $fields[ $result->id ] = $result; |
| 336 | - $count++; |
|
| 337 | - if ( $limit == 1 ) { |
|
| 338 | - $fields = $result; |
|
| 339 | - break; |
|
| 340 | - } |
|
| 336 | + $count++; |
|
| 337 | + if ( $limit == 1 ) { |
|
| 338 | + $fields = $result; |
|
| 339 | + break; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - if ( ! empty($limit) && $count >= $limit ) { |
|
| 343 | - break; |
|
| 344 | - } |
|
| 342 | + if ( ! empty($limit) && $count >= $limit ) { |
|
| 343 | + break; |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - unset($result); |
|
| 347 | - } |
|
| 348 | - return stripslashes_deep($fields); |
|
| 349 | - } |
|
| 346 | + unset($result); |
|
| 347 | + } |
|
| 348 | + return stripslashes_deep($fields); |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - self::$use_cache = false; |
|
| 351 | + self::$use_cache = false; |
|
| 352 | 352 | |
| 353 | 353 | $where = array( |
| 354 | 354 | 'fi.form_id' => (int) $form_id, |
@@ -356,64 +356,64 @@ discard block |
||
| 356 | 356 | ); |
| 357 | 357 | self::maybe_include_repeating_fields( $inc_sub, $where ); |
| 358 | 358 | $results = self::getAll( $where, 'field_order', $limit ); |
| 359 | - self::$use_cache = true; |
|
| 360 | - self::include_sub_fields($results, $inc_sub, $type); |
|
| 359 | + self::$use_cache = true; |
|
| 360 | + self::include_sub_fields($results, $inc_sub, $type); |
|
| 361 | 361 | |
| 362 | - return $results; |
|
| 363 | - } |
|
| 362 | + return $results; |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | 365 | public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) { |
| 366 | - if ( ! (int) $form_id ) { |
|
| 367 | - return array(); |
|
| 368 | - } |
|
| 366 | + if ( ! (int) $form_id ) { |
|
| 367 | + return array(); |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | 370 | $results = self::get_fields_from_transients( $form_id, array( |
| 371 | 371 | 'inc_embed' => $inc_embed, |
| 372 | 372 | 'inc_repeat' => $inc_repeat, |
| 373 | 373 | ) ); |
| 374 | 374 | if ( ! empty( $results ) ) { |
| 375 | - if ( empty($limit) ) { |
|
| 375 | + if ( empty($limit) ) { |
|
| 376 | 376 | return $results; |
| 377 | - } |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - $fields = array(); |
|
| 380 | - $count = 0; |
|
| 381 | - foreach ( $results as $result ) { |
|
| 379 | + $fields = array(); |
|
| 380 | + $count = 0; |
|
| 381 | + foreach ( $results as $result ) { |
|
| 382 | 382 | $fields[ $result->id ] = $result; |
| 383 | - if ( ! empty($limit) && $count >= $limit ) { |
|
| 384 | - break; |
|
| 385 | - } |
|
| 386 | - } |
|
| 383 | + if ( ! empty($limit) && $count >= $limit ) { |
|
| 384 | + break; |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | 388 | return $fields; |
| 389 | - } |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - self::$use_cache = false; |
|
| 391 | + self::$use_cache = false; |
|
| 392 | 392 | |
| 393 | 393 | $where = array( 'fi.form_id' => absint( $form_id ) ); |
| 394 | 394 | self::maybe_include_repeating_fields( $inc_repeat, $where ); |
| 395 | 395 | $results = self::getAll( $where, 'field_order', $limit ); |
| 396 | 396 | |
| 397 | - self::$use_cache = true; |
|
| 397 | + self::$use_cache = true; |
|
| 398 | 398 | |
| 399 | 399 | self::include_sub_fields( $results, $inc_embed, 'all' ); |
| 400 | 400 | |
| 401 | - if ( empty($limit) ) { |
|
| 401 | + if ( empty($limit) ) { |
|
| 402 | 402 | self::set_field_transient( $results, $form_id, 0, array( |
| 403 | 403 | 'inc_embed' => $inc_embed, |
| 404 | 404 | 'inc_repeat' => $inc_repeat, |
| 405 | 405 | ) ); |
| 406 | - } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | 408 | return $results; |
| 409 | - } |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | - * If repeating fields should be included, adjust $where accordingly |
|
| 413 | - * |
|
| 414 | - * @param string $inc_repeat |
|
| 415 | - * @param array $where - pass by reference |
|
| 416 | - */ |
|
| 412 | + * If repeating fields should be included, adjust $where accordingly |
|
| 413 | + * |
|
| 414 | + * @param string $inc_repeat |
|
| 415 | + * @param array $where - pass by reference |
|
| 416 | + */ |
|
| 417 | 417 | private static function maybe_include_repeating_fields( $inc_repeat, &$where ) { |
| 418 | 418 | if ( $inc_repeat == 'include' ) { |
| 419 | 419 | $form_id = $where['fi.form_id']; |
@@ -428,57 +428,57 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) { |
| 430 | 430 | if ( 'include' != $inc_embed || empty( $results ) ) { |
| 431 | - return; |
|
| 432 | - } |
|
| 431 | + return; |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | - $form_fields = $results; |
|
| 434 | + $form_fields = $results; |
|
| 435 | 435 | $index_offset = 1; |
| 436 | - foreach ( $form_fields as $k => $field ) { |
|
| 437 | - if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
| 438 | - continue; |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - if ( $type == 'all' ) { |
|
| 442 | - $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
| 443 | - } else { |
|
| 444 | - $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - if ( ! empty($sub_fields) ) { |
|
| 436 | + foreach ( $form_fields as $k => $field ) { |
|
| 437 | + if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
| 438 | + continue; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + if ( $type == 'all' ) { |
|
| 442 | + $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
| 443 | + } else { |
|
| 444 | + $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + if ( ! empty($sub_fields) ) { |
|
| 448 | 448 | $index = $k + $index_offset; |
| 449 | 449 | $index_offset += count( $sub_fields ); |
| 450 | 450 | array_splice($results, $index, 0, $sub_fields); |
| 451 | - } |
|
| 452 | - unset($field, $sub_fields); |
|
| 453 | - } |
|
| 454 | - } |
|
| 451 | + } |
|
| 452 | + unset($field, $sub_fields); |
|
| 453 | + } |
|
| 454 | + } |
|
| 455 | 455 | |
| 456 | 456 | public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) { |
| 457 | 457 | $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id; |
| 458 | - if ( self::$use_cache ) { |
|
| 459 | - // make sure old cache doesn't get saved as a transient |
|
| 460 | - $results = wp_cache_get($cache_key, 'frm_field'); |
|
| 461 | - if ( false !== $results ) { |
|
| 462 | - return stripslashes_deep($results); |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - global $wpdb; |
|
| 467 | - |
|
| 468 | - if ( $blog_id && is_multisite() ) { |
|
| 469 | - global $wpmuBaseTablePrefix; |
|
| 470 | - if ( $wpmuBaseTablePrefix ) { |
|
| 458 | + if ( self::$use_cache ) { |
|
| 459 | + // make sure old cache doesn't get saved as a transient |
|
| 460 | + $results = wp_cache_get($cache_key, 'frm_field'); |
|
| 461 | + if ( false !== $results ) { |
|
| 462 | + return stripslashes_deep($results); |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + global $wpdb; |
|
| 467 | + |
|
| 468 | + if ( $blog_id && is_multisite() ) { |
|
| 469 | + global $wpmuBaseTablePrefix; |
|
| 470 | + if ( $wpmuBaseTablePrefix ) { |
|
| 471 | 471 | $prefix = $wpmuBaseTablePrefix . $blog_id . '_'; |
| 472 | - } else { |
|
| 473 | - $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
| 474 | - } |
|
| 472 | + } else { |
|
| 473 | + $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | 476 | $table_name = $prefix . 'frm_fields'; |
| 477 | 477 | $form_table_name = $prefix . 'frm_forms'; |
| 478 | 478 | } else { |
| 479 | 479 | $table_name = $wpdb->prefix . 'frm_fields'; |
| 480 | 480 | $form_table_name = $wpdb->prefix . 'frm_forms'; |
| 481 | - } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | 483 | if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) { |
| 484 | 484 | $order_by = ' ORDER BY ' . $order_by; |
@@ -486,8 +486,8 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | $limit = FrmDb::esc_limit( $limit ); |
| 488 | 488 | |
| 489 | - $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
| 490 | - $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
| 489 | + $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
| 490 | + $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
| 491 | 491 | |
| 492 | 492 | if ( is_array( $where ) ) { |
| 493 | 493 | $args = array( |
@@ -501,8 +501,8 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results'; |
| 503 | 503 | $results = $wpdb->$function_name( $query ); |
| 504 | - } |
|
| 505 | - unset( $where ); |
|
| 504 | + } |
|
| 505 | + unset( $where ); |
|
| 506 | 506 | |
| 507 | 507 | self::format_field_results( $results ); |
| 508 | 508 | |
@@ -735,8 +735,8 @@ discard block |
||
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | /** |
| 738 | - * @since 2.0.09 |
|
| 739 | - */ |
|
| 738 | + * @since 2.0.09 |
|
| 739 | + */ |
|
| 740 | 740 | public static function is_repeating_field( $field ) { |
| 741 | 741 | if ( is_array( $field ) ) { |
| 742 | 742 | $is_repeating_field = ( 'divider' == $field['type'] ); |
@@ -746,14 +746,14 @@ discard block |
||
| 746 | 746 | return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) ); |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - /** |
|
| 750 | - * @param string $key |
|
| 751 | - * @return int field id |
|
| 752 | - */ |
|
| 749 | + /** |
|
| 750 | + * @param string $key |
|
| 751 | + * @return int field id |
|
| 752 | + */ |
|
| 753 | 753 | public static function get_id_by_key( $key ) { |
| 754 | - $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
| 755 | - return $id; |
|
| 756 | - } |
|
| 754 | + $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
| 755 | + return $id; |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | 758 | /** |
| 759 | 759 | * @param string $id |
@@ -5,63 +5,63 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class FrmEntriesHelper { |
| 7 | 7 | |
| 8 | - public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
| 8 | + public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
| 9 | 9 | $values = array( |
| 10 | 10 | 'name' => '', |
| 11 | 11 | 'description' => '', |
| 12 | 12 | 'item_key' => '', |
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | - $values['fields'] = array(); |
|
| 16 | - if ( empty($fields) ) { |
|
| 17 | - return apply_filters('frm_setup_new_entry', $values); |
|
| 18 | - } |
|
| 15 | + $values['fields'] = array(); |
|
| 16 | + if ( empty($fields) ) { |
|
| 17 | + return apply_filters('frm_setup_new_entry', $values); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - foreach ( (array) $fields as $field ) { |
|
| 20 | + foreach ( (array) $fields as $field ) { |
|
| 21 | 21 | self::prepare_field_default_value( $field ); |
| 22 | - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
| 23 | - |
|
| 24 | - $field_array = array( |
|
| 25 | - 'id' => $field->id, |
|
| 26 | - 'value' => $new_value, |
|
| 27 | - 'default_value' => $field->default_value, |
|
| 28 | - 'name' => $field->name, |
|
| 29 | - 'description' => $field->description, |
|
| 30 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 31 | - 'options' => $field->options, |
|
| 32 | - 'required' => $field->required, |
|
| 33 | - 'field_key' => $field->field_key, |
|
| 34 | - 'field_order' => $field->field_order, |
|
| 35 | - 'form_id' => $field->form_id, |
|
| 22 | + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
| 23 | + |
|
| 24 | + $field_array = array( |
|
| 25 | + 'id' => $field->id, |
|
| 26 | + 'value' => $new_value, |
|
| 27 | + 'default_value' => $field->default_value, |
|
| 28 | + 'name' => $field->name, |
|
| 29 | + 'description' => $field->description, |
|
| 30 | + 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 31 | + 'options' => $field->options, |
|
| 32 | + 'required' => $field->required, |
|
| 33 | + 'field_key' => $field->field_key, |
|
| 34 | + 'field_order' => $field->field_order, |
|
| 35 | + 'form_id' => $field->form_id, |
|
| 36 | 36 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
| 37 | - 'reset_value' => $reset, |
|
| 37 | + 'reset_value' => $reset, |
|
| 38 | 38 | 'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0', |
| 39 | - ); |
|
| 39 | + ); |
|
| 40 | 40 | |
| 41 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 42 | - $opt_defaults['required_indicator'] = ''; |
|
| 41 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 42 | + $opt_defaults['required_indicator'] = ''; |
|
| 43 | 43 | $opt_defaults['original_type'] = $field->type; |
| 44 | 44 | |
| 45 | 45 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 46 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 47 | - unset($opt, $default_opt); |
|
| 48 | - } |
|
| 46 | + $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 47 | + unset($opt, $default_opt); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - unset($opt_defaults); |
|
| 50 | + unset($opt_defaults); |
|
| 51 | 51 | |
| 52 | - if ( $field_array['custom_html'] == '' ) { |
|
| 53 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 54 | - } |
|
| 52 | + if ( $field_array['custom_html'] == '' ) { |
|
| 53 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 57 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 56 | + $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 57 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 58 | 58 | |
| 59 | - $values['fields'][] = $field_array; |
|
| 59 | + $values['fields'][] = $field_array; |
|
| 60 | 60 | |
| 61 | - if ( ! $form || ! isset($form->id) ) { |
|
| 62 | - $form = FrmForm::getOne($field->form_id); |
|
| 63 | - } |
|
| 64 | - } |
|
| 61 | + if ( ! $form || ! isset($form->id) ) { |
|
| 62 | + $form = FrmForm::getOne($field->form_id); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | $form->options = maybe_unserialize( $form->options ); |
| 67 | 67 | if ( is_array( $form->options ) ) { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $values = array_merge( $form_defaults, $values ); |
| 77 | 77 | |
| 78 | 78 | return apply_filters( 'frm_setup_new_entry', $values ); |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * @since 2.05 |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * Set the value for each field |
|
| 95 | - * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
| 96 | - * |
|
| 97 | - * @since 2.0.13 |
|
| 98 | - * |
|
| 99 | - * @param object $field - this is passed by reference since it is an object |
|
| 100 | - * @param boolean $reset |
|
| 101 | - * @param array $args |
|
| 102 | - * @return string|array $new_value |
|
| 103 | - */ |
|
| 94 | + * Set the value for each field |
|
| 95 | + * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
| 96 | + * |
|
| 97 | + * @since 2.0.13 |
|
| 98 | + * |
|
| 99 | + * @param object $field - this is passed by reference since it is an object |
|
| 100 | + * @param boolean $reset |
|
| 101 | + * @param array $args |
|
| 102 | + * @return string|array $new_value |
|
| 103 | + */ |
|
| 104 | 104 | private static function get_field_value_for_new_entry( $field, $reset, $args ) { |
| 105 | 105 | $new_value = $field->default_value; |
| 106 | 106 | |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * Check if a field has a posted value |
|
| 129 | - * |
|
| 130 | - * @since 2.01.0 |
|
| 131 | - * @param object $field |
|
| 132 | - * @param array $args |
|
| 133 | - * @return boolean $value_is_posted |
|
| 134 | - */ |
|
| 128 | + * Check if a field has a posted value |
|
| 129 | + * |
|
| 130 | + * @since 2.01.0 |
|
| 131 | + * @param object $field |
|
| 132 | + * @param array $args |
|
| 133 | + * @return boolean $value_is_posted |
|
| 134 | + */ |
|
| 135 | 135 | public static function value_is_posted( $field, $args ) { |
| 136 | 136 | $value_is_posted = false; |
| 137 | 137 | if ( $_POST ) { |
@@ -149,15 +149,15 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | public static function setup_edit_vars( $values, $record ) { |
| 151 | 151 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
| 152 | - $values['form_id'] = $record->form_id; |
|
| 153 | - $values['is_draft'] = $record->is_draft; |
|
| 154 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 155 | - } |
|
| 152 | + $values['form_id'] = $record->form_id; |
|
| 153 | + $values['is_draft'] = $record->is_draft; |
|
| 154 | + return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - public static function get_admin_params( $form = null ) { |
|
| 157 | + public static function get_admin_params( $form = null ) { |
|
| 158 | 158 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' ); |
| 159 | 159 | return FrmForm::set_current_form( $form ); |
| 160 | - } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | 162 | public static function set_current_form( $form_id ) { |
| 163 | 163 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' ); |
@@ -169,101 +169,101 @@ discard block |
||
| 169 | 169 | return FrmForm::get_current_form( $form_id ); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - public static function get_current_form_id() { |
|
| 172 | + public static function get_current_form_id() { |
|
| 173 | 173 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' ); |
| 174 | 174 | return FrmForm::get_current_form_id(); |
| 175 | - } |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - public static function maybe_get_entry( &$entry ) { |
|
| 177 | + public static function maybe_get_entry( &$entry ) { |
|
| 178 | 178 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' ); |
| 179 | 179 | FrmEntry::maybe_get_entry( $entry ); |
| 180 | - } |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | 182 | public static function replace_default_message( $message, $atts ) { |
| 183 | - if ( strpos($message, '[default-message') === false && |
|
| 184 | - strpos($message, '[default_message') === false && |
|
| 185 | - ! empty( $message ) ) { |
|
| 186 | - return $message; |
|
| 187 | - } |
|
| 183 | + if ( strpos($message, '[default-message') === false && |
|
| 184 | + strpos($message, '[default_message') === false && |
|
| 185 | + ! empty( $message ) ) { |
|
| 186 | + return $message; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - if ( empty($message) ) { |
|
| 190 | - $message = '[default-message]'; |
|
| 191 | - } |
|
| 189 | + if ( empty($message) ) { |
|
| 190 | + $message = '[default-message]'; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 193 | + preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 194 | 194 | |
| 195 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 195 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 196 | 196 | $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
| 197 | 197 | if ( ! empty( $add_atts ) ) { |
| 198 | - $this_atts = array_merge($atts, $add_atts); |
|
| 199 | - } else { |
|
| 200 | - $this_atts = $atts; |
|
| 201 | - } |
|
| 198 | + $this_atts = array_merge($atts, $add_atts); |
|
| 199 | + } else { |
|
| 200 | + $this_atts = $atts; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
| 204 | 204 | |
| 205 | - // Add the default message |
|
| 206 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 207 | - } |
|
| 205 | + // Add the default message |
|
| 206 | + $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - return $message; |
|
| 210 | - } |
|
| 209 | + return $message; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | 212 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 213 | 213 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
| 214 | 214 | |
| 215 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 215 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 216 | 216 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 220 | - return self::display_value($field_value, $field, $atts); |
|
| 221 | - } |
|
| 219 | + if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 220 | + return self::display_value($field_value, $field, $atts); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - // this is an embeded form |
|
| 224 | - $val = ''; |
|
| 223 | + // this is an embeded form |
|
| 224 | + $val = ''; |
|
| 225 | 225 | |
| 226 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 227 | - //this is a repeating section |
|
| 226 | + if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 227 | + //this is a repeating section |
|
| 228 | 228 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
| 229 | - } else { |
|
| 230 | - // get all values for this field |
|
| 231 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 229 | + } else { |
|
| 230 | + // get all values for this field |
|
| 231 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 232 | 232 | |
| 233 | - if ( $child_values ) { |
|
| 234 | - $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
| 235 | - } |
|
| 236 | - } |
|
| 233 | + if ( $child_values ) { |
|
| 234 | + $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - $field_value = array(); |
|
| 238 | + $field_value = array(); |
|
| 239 | 239 | |
| 240 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 241 | - return $val; |
|
| 242 | - } |
|
| 240 | + if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 241 | + return $val; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - foreach ( $child_entries as $child_entry ) { |
|
| 245 | - $atts['item_id'] = $child_entry->id; |
|
| 246 | - $atts['post_id'] = $child_entry->post_id; |
|
| 244 | + foreach ( $child_entries as $child_entry ) { |
|
| 245 | + $atts['item_id'] = $child_entry->id; |
|
| 246 | + $atts['post_id'] = $child_entry->post_id; |
|
| 247 | 247 | |
| 248 | - // get the value for this field -- check for post values as well |
|
| 249 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 248 | + // get the value for this field -- check for post values as well |
|
| 249 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 250 | 250 | |
| 251 | - if ( $entry_val ) { |
|
| 252 | - // foreach entry get display_value |
|
| 253 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 254 | - } |
|
| 251 | + if ( $entry_val ) { |
|
| 252 | + // foreach entry get display_value |
|
| 253 | + $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - unset($child_entry); |
|
| 257 | - } |
|
| 256 | + unset($child_entry); |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - $val = implode(', ', (array) $field_value ); |
|
| 259 | + $val = implode(', ', (array) $field_value ); |
|
| 260 | 260 | return FrmAppHelper::kses( $val, 'all' ); |
| 261 | - } |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - /** |
|
| 264 | - * Prepare the saved value for display |
|
| 265 | - * @return string |
|
| 266 | - */ |
|
| 263 | + /** |
|
| 264 | + * Prepare the saved value for display |
|
| 265 | + * @return string |
|
| 266 | + */ |
|
| 267 | 267 | public static function display_value( $value, $field, $atts = array() ) { |
| 268 | 268 | |
| 269 | 269 | $defaults = array( |
@@ -279,178 +279,178 @@ discard block |
||
| 279 | 279 | 'return_array' => false, |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 283 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 282 | + $atts = wp_parse_args( $atts, $defaults ); |
|
| 283 | + $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 284 | 284 | |
| 285 | - if ( ! isset($field->field_options['post_field']) ) { |
|
| 286 | - $field->field_options['post_field'] = ''; |
|
| 287 | - } |
|
| 285 | + if ( ! isset($field->field_options['post_field']) ) { |
|
| 286 | + $field->field_options['post_field'] = ''; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 290 | - $field->field_options['custom_field'] = ''; |
|
| 291 | - } |
|
| 289 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 290 | + $field->field_options['custom_field'] = ''; |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
| 294 | - $atts['pre_truncate'] = $atts['truncate']; |
|
| 295 | - $atts['truncate'] = true; |
|
| 296 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 293 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
| 294 | + $atts['pre_truncate'] = $atts['truncate']; |
|
| 295 | + $atts['truncate'] = true; |
|
| 296 | + $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 297 | 297 | |
| 298 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 299 | - $atts['truncate'] = $atts['pre_truncate']; |
|
| 300 | - } |
|
| 298 | + $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 299 | + $atts['truncate'] = $atts['pre_truncate']; |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - if ( $value == '' ) { |
|
| 303 | - return $value; |
|
| 304 | - } |
|
| 302 | + if ( $value == '' ) { |
|
| 303 | + return $value; |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 306 | + $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 307 | 307 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
| 308 | 308 | |
| 309 | - $new_value = ''; |
|
| 309 | + $new_value = ''; |
|
| 310 | 310 | |
| 311 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 312 | - foreach ( $value as $val ) { |
|
| 313 | - if ( is_array($val) ) { |
|
| 311 | + if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 312 | + foreach ( $value as $val ) { |
|
| 313 | + if ( is_array($val) ) { |
|
| 314 | 314 | //TODO: add options for display (li or ,) |
| 315 | - $new_value .= implode($atts['sep'], $val); |
|
| 316 | - if ( $atts['type'] != 'data' ) { |
|
| 317 | - $new_value .= '<br/>'; |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - unset($val); |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - if ( ! empty($new_value) ) { |
|
| 325 | - $value = $new_value; |
|
| 326 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 327 | - $value = implode($atts['sep'], $value); |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
| 331 | - $value = FrmAppHelper::truncate($value, 50); |
|
| 332 | - } |
|
| 315 | + $new_value .= implode($atts['sep'], $val); |
|
| 316 | + if ( $atts['type'] != 'data' ) { |
|
| 317 | + $new_value .= '<br/>'; |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + unset($val); |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + if ( ! empty($new_value) ) { |
|
| 325 | + $value = $new_value; |
|
| 326 | + } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 327 | + $value = implode($atts['sep'], $value); |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
| 331 | + $value = FrmAppHelper::truncate($value, 50); |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | 334 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
| 335 | 335 | $value = FrmAppHelper::kses( $value, 'all' ); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 339 | - } |
|
| 338 | + return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | 341 | public static function set_posted_value( $field, $value, $args ) { |
| 342 | - // If validating a field with "other" opt, set back to prev value now |
|
| 343 | - if ( isset( $args['other'] ) && $args['other'] ) { |
|
| 344 | - $value = $args['temp_value']; |
|
| 345 | - } |
|
| 346 | - if ( empty($args['parent_field_id']) ) { |
|
| 347 | - $_POST['item_meta'][ $field->id ] = $value; |
|
| 348 | - } else { |
|
| 349 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 350 | - } |
|
| 351 | - } |
|
| 342 | + // If validating a field with "other" opt, set back to prev value now |
|
| 343 | + if ( isset( $args['other'] ) && $args['other'] ) { |
|
| 344 | + $value = $args['temp_value']; |
|
| 345 | + } |
|
| 346 | + if ( empty($args['parent_field_id']) ) { |
|
| 347 | + $_POST['item_meta'][ $field->id ] = $value; |
|
| 348 | + } else { |
|
| 349 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | 353 | public static function get_posted_value( $field, &$value, $args ) { |
| 354 | 354 | $field_id = is_object( $field ) ? $field->id : $field; |
| 355 | 355 | |
| 356 | - if ( empty($args['parent_field_id']) ) { |
|
| 357 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 358 | - } else { |
|
| 359 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
| 360 | - } |
|
| 356 | + if ( empty($args['parent_field_id']) ) { |
|
| 357 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 358 | + } else { |
|
| 359 | + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
| 360 | + } |
|
| 361 | 361 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 362 | 362 | $value = stripslashes_deep( $value ); |
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * Check if field has an "Other" option and if any other values are posted |
|
| 367 | - * |
|
| 368 | - * @since 2.0 |
|
| 369 | - * |
|
| 370 | - * @param object $field |
|
| 371 | - * @param string|array $value |
|
| 372 | - * @param array $args |
|
| 373 | - */ |
|
| 374 | - public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
| 375 | - $args['other'] = false; |
|
| 376 | - if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
| 377 | - return; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - // Get other value for fields in repeating section |
|
| 381 | - self::set_other_repeating_vals( $field, $value, $args ); |
|
| 382 | - |
|
| 383 | - // Check if there are any posted "Other" values |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * Check if field has an "Other" option and if any other values are posted |
|
| 367 | + * |
|
| 368 | + * @since 2.0 |
|
| 369 | + * |
|
| 370 | + * @param object $field |
|
| 371 | + * @param string|array $value |
|
| 372 | + * @param array $args |
|
| 373 | + */ |
|
| 374 | + public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
| 375 | + $args['other'] = false; |
|
| 376 | + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
| 377 | + return; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + // Get other value for fields in repeating section |
|
| 381 | + self::set_other_repeating_vals( $field, $value, $args ); |
|
| 382 | + |
|
| 383 | + // Check if there are any posted "Other" values |
|
| 384 | 384 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
| 385 | 385 | |
| 386 | - // Save original value |
|
| 387 | - $args['temp_value'] = $value; |
|
| 388 | - $args['other'] = true; |
|
| 389 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 390 | - |
|
| 391 | - // Set the validation value now |
|
| 392 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
| 398 | - * |
|
| 399 | - * @since 2.0 |
|
| 400 | - * |
|
| 401 | - * @param object $field |
|
| 402 | - * @param string|array $value |
|
| 403 | - * @param array $args |
|
| 404 | - */ |
|
| 405 | - public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
| 406 | - if ( ! $args['parent_field_id'] ) { |
|
| 407 | - return; |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - // Check if there are any other posted "other" values for this field |
|
| 386 | + // Save original value |
|
| 387 | + $args['temp_value'] = $value; |
|
| 388 | + $args['other'] = true; |
|
| 389 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 390 | + |
|
| 391 | + // Set the validation value now |
|
| 392 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
| 398 | + * |
|
| 399 | + * @since 2.0 |
|
| 400 | + * |
|
| 401 | + * @param object $field |
|
| 402 | + * @param string|array $value |
|
| 403 | + * @param array $args |
|
| 404 | + */ |
|
| 405 | + public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
| 406 | + if ( ! $args['parent_field_id'] ) { |
|
| 407 | + return; |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + // Check if there are any other posted "other" values for this field |
|
| 411 | 411 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
| 412 | - // Save original value |
|
| 413 | - $args['temp_value'] = $value; |
|
| 414 | - $args['other'] = true; |
|
| 415 | - |
|
| 416 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 417 | - |
|
| 418 | - // Set the validation value now |
|
| 419 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * Modify value used for validation |
|
| 425 | - * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
| 426 | - * It also adds any text from the free text fields to the value |
|
| 427 | - * |
|
| 428 | - * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
| 429 | - * |
|
| 430 | - * @since 2.0 |
|
| 431 | - * |
|
| 432 | - * @param string|array $value |
|
| 433 | - * @param string|array $other_vals (usually of posted values) |
|
| 434 | - * @param object $field |
|
| 435 | - * @param array $args |
|
| 436 | - */ |
|
| 437 | - public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
| 438 | - // Checkboxes and multi-select dropdowns |
|
| 439 | - if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
| 440 | - // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
| 441 | - $value = array_merge( $value, $other_vals ); |
|
| 442 | - $value = array_filter( $value ); |
|
| 443 | - if ( count( $value ) == 0 ) { |
|
| 444 | - $value = ''; |
|
| 445 | - } |
|
| 446 | - } else { |
|
| 412 | + // Save original value |
|
| 413 | + $args['temp_value'] = $value; |
|
| 414 | + $args['other'] = true; |
|
| 415 | + |
|
| 416 | + $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 417 | + |
|
| 418 | + // Set the validation value now |
|
| 419 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * Modify value used for validation |
|
| 425 | + * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
| 426 | + * It also adds any text from the free text fields to the value |
|
| 427 | + * |
|
| 428 | + * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
| 429 | + * |
|
| 430 | + * @since 2.0 |
|
| 431 | + * |
|
| 432 | + * @param string|array $value |
|
| 433 | + * @param string|array $other_vals (usually of posted values) |
|
| 434 | + * @param object $field |
|
| 435 | + * @param array $args |
|
| 436 | + */ |
|
| 437 | + public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
| 438 | + // Checkboxes and multi-select dropdowns |
|
| 439 | + if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
| 440 | + // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
| 441 | + $value = array_merge( $value, $other_vals ); |
|
| 442 | + $value = array_filter( $value ); |
|
| 443 | + if ( count( $value ) == 0 ) { |
|
| 444 | + $value = ''; |
|
| 445 | + } |
|
| 446 | + } else { |
|
| 447 | 447 | // Radio and dropdowns |
| 448 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 449 | - $other_key = reset( $other_key ); |
|
| 448 | + $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 449 | + $other_key = reset( $other_key ); |
|
| 450 | 450 | |
| 451 | - // Multi-select dropdown |
|
| 452 | - if ( is_array( $value ) ) { |
|
| 453 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 451 | + // Multi-select dropdown |
|
| 452 | + if ( is_array( $value ) ) { |
|
| 453 | + $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 454 | 454 | |
| 455 | 455 | if ( $o_key !== false ) { |
| 456 | 456 | // Modify the original value so other key will be preserved |
@@ -465,20 +465,20 @@ discard block |
||
| 465 | 465 | $args['temp_value'] = $value; |
| 466 | 466 | $value[ $other_key ] = reset( $other_vals ); |
| 467 | 467 | } |
| 468 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
| 469 | - $value = $other_vals; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - } |
|
| 468 | + } else if ( $field->options[ $other_key ] == $value ) { |
|
| 469 | + $value = $other_vals; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | 474 | public static function enqueue_scripts( $params ) { |
| 475 | 475 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' ); |
| 476 | 476 | FrmFormsController::enqueue_scripts( $params ); |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - // Add submitted values to a string for spam checking |
|
| 479 | + // Add submitted values to a string for spam checking |
|
| 480 | 480 | public static function entry_array_to_string( $values ) { |
| 481 | - $content = ''; |
|
| 481 | + $content = ''; |
|
| 482 | 482 | foreach ( $values['item_meta'] as $val ) { |
| 483 | 483 | if ( $content != '' ) { |
| 484 | 484 | $content .= "\n\n"; |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | return $content; |
| 496 | - } |
|
| 496 | + } |
|
| 497 | 497 | |
| 498 | 498 | /** |
| 499 | 499 | * Get the browser from the user agent |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | 15 | $values['fields'] = array(); |
| 16 | - if ( empty($fields) ) { |
|
| 17 | - return apply_filters('frm_setup_new_entry', $values); |
|
| 16 | + if ( empty( $fields ) ) { |
|
| 17 | + return apply_filters( 'frm_setup_new_entry', $values ); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | foreach ( (array) $fields as $field ) { |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | 'default_value' => $field->default_value, |
| 28 | 28 | 'name' => $field->name, |
| 29 | 29 | 'description' => $field->description, |
| 30 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 30 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), |
|
| 31 | 31 | 'options' => $field->options, |
| 32 | 32 | 'required' => $field->required, |
| 33 | 33 | 'field_key' => $field->field_key, |
@@ -38,28 +38,28 @@ discard block |
||
| 38 | 38 | 'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0', |
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 41 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
| 42 | 42 | $opt_defaults['required_indicator'] = ''; |
| 43 | 43 | $opt_defaults['original_type'] = $field->type; |
| 44 | 44 | |
| 45 | 45 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 46 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 47 | - unset($opt, $default_opt); |
|
| 46 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; |
|
| 47 | + unset( $opt, $default_opt ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - unset($opt_defaults); |
|
| 50 | + unset( $opt_defaults ); |
|
| 51 | 51 | |
| 52 | 52 | if ( $field_array['custom_html'] == '' ) { |
| 53 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 53 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 56 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 57 | 57 | $field_array = array_merge( $field->field_options, $field_array ); |
| 58 | 58 | |
| 59 | 59 | $values['fields'][] = $field_array; |
| 60 | 60 | |
| 61 | - if ( ! $form || ! isset($form->id) ) { |
|
| 62 | - $form = FrmForm::getOne($field->form_id); |
|
| 61 | + if ( ! $form || ! isset( $form->id ) ) { |
|
| 62 | + $form = FrmForm::getOne( $field->form_id ); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 72 | 72 | |
| 73 | 73 | $frm_settings = FrmAppHelper::get_settings(); |
| 74 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
| 74 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
| 75 | 75 | |
| 76 | 76 | $values = array_merge( $form_defaults, $values ); |
| 77 | 77 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | if ( ! is_array( $new_value ) ) { |
| 121 | - $new_value = str_replace('"', '"', $new_value); |
|
| 121 | + $new_value = str_replace( '"', '"', $new_value ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return $new_value; |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | if ( $_POST ) { |
| 138 | 138 | $repeating = isset( $args['repeating'] ) && $args['repeating']; |
| 139 | 139 | if ( $repeating ) { |
| 140 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { |
|
| 140 | + if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) { |
|
| 141 | 141 | $value_is_posted = true; |
| 142 | 142 | } |
| 143 | - } else if ( isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
| 143 | + } else if ( isset( $_POST['item_meta'][$field->id] ) ) { |
|
| 144 | 144 | $value_is_posted = true; |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
| 152 | 152 | $values['form_id'] = $record->form_id; |
| 153 | 153 | $values['is_draft'] = $record->is_draft; |
| 154 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 154 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public static function get_admin_params( $form = null ) { |
@@ -180,22 +180,22 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public static function replace_default_message( $message, $atts ) { |
| 183 | - if ( strpos($message, '[default-message') === false && |
|
| 184 | - strpos($message, '[default_message') === false && |
|
| 183 | + if ( strpos( $message, '[default-message' ) === false && |
|
| 184 | + strpos( $message, '[default_message' ) === false && |
|
| 185 | 185 | ! empty( $message ) ) { |
| 186 | 186 | return $message; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( empty($message) ) { |
|
| 189 | + if ( empty( $message ) ) { |
|
| 190 | 190 | $message = '[default-message]'; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 193 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
|
| 194 | 194 | |
| 195 | 195 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 196 | - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 196 | + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
| 197 | 197 | if ( ! empty( $add_atts ) ) { |
| 198 | - $this_atts = array_merge($atts, $add_atts); |
|
| 198 | + $this_atts = array_merge( $atts, $add_atts ); |
|
| 199 | 199 | } else { |
| 200 | 200 | $this_atts = $atts; |
| 201 | 201 | } |
@@ -203,32 +203,32 @@ discard block |
||
| 203 | 203 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
| 204 | 204 | |
| 205 | 205 | // Add the default message |
| 206 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 206 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | return $message; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 213 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
| 213 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
| 214 | 214 | |
| 215 | 215 | if ( FrmAppHelper::pro_is_installed() ) { |
| 216 | 216 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 220 | - return self::display_value($field_value, $field, $atts); |
|
| 219 | + if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
|
| 220 | + return self::display_value( $field_value, $field, $atts ); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // this is an embeded form |
| 224 | 224 | $val = ''; |
| 225 | 225 | |
| 226 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 226 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
|
| 227 | 227 | //this is a repeating section |
| 228 | 228 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
| 229 | 229 | } else { |
| 230 | 230 | // get all values for this field |
| 231 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 231 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
| 232 | 232 | |
| 233 | 233 | if ( $child_values ) { |
| 234 | 234 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $field_value = array(); |
| 239 | 239 | |
| 240 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 240 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 241 | 241 | return $val; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -246,17 +246,17 @@ discard block |
||
| 246 | 246 | $atts['post_id'] = $child_entry->post_id; |
| 247 | 247 | |
| 248 | 248 | // get the value for this field -- check for post values as well |
| 249 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 249 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
|
| 250 | 250 | |
| 251 | 251 | if ( $entry_val ) { |
| 252 | 252 | // foreach entry get display_value |
| 253 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 253 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - unset($child_entry); |
|
| 256 | + unset( $child_entry ); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $val = implode(', ', (array) $field_value ); |
|
| 259 | + $val = implode( ', ', (array) $field_value ); |
|
| 260 | 260 | return FrmAppHelper::kses( $val, 'all' ); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -280,22 +280,22 @@ discard block |
||
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | 282 | $atts = wp_parse_args( $atts, $defaults ); |
| 283 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 283 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
|
| 284 | 284 | |
| 285 | - if ( ! isset($field->field_options['post_field']) ) { |
|
| 285 | + if ( ! isset( $field->field_options['post_field'] ) ) { |
|
| 286 | 286 | $field->field_options['post_field'] = ''; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 289 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
| 290 | 290 | $field->field_options['custom_field'] = ''; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
| 294 | 294 | $atts['pre_truncate'] = $atts['truncate']; |
| 295 | 295 | $atts['truncate'] = true; |
| 296 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 296 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
|
| 297 | 297 | |
| 298 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 298 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
|
| 299 | 299 | $atts['truncate'] = $atts['pre_truncate']; |
| 300 | 300 | } |
| 301 | 301 | |
@@ -303,39 +303,39 @@ discard block |
||
| 303 | 303 | return $value; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 306 | + $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts ); |
|
| 307 | 307 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
| 308 | 308 | |
| 309 | 309 | $new_value = ''; |
| 310 | 310 | |
| 311 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 311 | + if ( is_array( $value ) && $atts['type'] != 'file' ) { |
|
| 312 | 312 | foreach ( $value as $val ) { |
| 313 | - if ( is_array($val) ) { |
|
| 313 | + if ( is_array( $val ) ) { |
|
| 314 | 314 | //TODO: add options for display (li or ,) |
| 315 | - $new_value .= implode($atts['sep'], $val); |
|
| 315 | + $new_value .= implode( $atts['sep'], $val ); |
|
| 316 | 316 | if ( $atts['type'] != 'data' ) { |
| 317 | 317 | $new_value .= '<br/>'; |
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | - unset($val); |
|
| 320 | + unset( $val ); |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if ( ! empty($new_value) ) { |
|
| 324 | + if ( ! empty( $new_value ) ) { |
|
| 325 | 325 | $value = $new_value; |
| 326 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 327 | - $value = implode($atts['sep'], $value); |
|
| 326 | + } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 327 | + $value = implode( $atts['sep'], $value ); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
| 331 | - $value = FrmAppHelper::truncate($value, 50); |
|
| 331 | + $value = FrmAppHelper::truncate( $value, 50 ); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
| 335 | 335 | $value = FrmAppHelper::kses( $value, 'all' ); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 338 | + return apply_filters( 'frm_display_value', $value, $field, $atts ); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | public static function set_posted_value( $field, $value, $args ) { |
@@ -343,20 +343,20 @@ discard block |
||
| 343 | 343 | if ( isset( $args['other'] ) && $args['other'] ) { |
| 344 | 344 | $value = $args['temp_value']; |
| 345 | 345 | } |
| 346 | - if ( empty($args['parent_field_id']) ) { |
|
| 347 | - $_POST['item_meta'][ $field->id ] = $value; |
|
| 346 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 347 | + $_POST['item_meta'][$field->id] = $value; |
|
| 348 | 348 | } else { |
| 349 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 349 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public static function get_posted_value( $field, &$value, $args ) { |
| 354 | 354 | $field_id = is_object( $field ) ? $field->id : $field; |
| 355 | 355 | |
| 356 | - if ( empty($args['parent_field_id']) ) { |
|
| 357 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 356 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 357 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; |
|
| 358 | 358 | } else { |
| 359 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
| 359 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : ''; |
|
| 360 | 360 | } |
| 361 | 361 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 362 | 362 | $value = stripslashes_deep( $value ); |
@@ -381,12 +381,12 @@ discard block |
||
| 381 | 381 | self::set_other_repeating_vals( $field, $value, $args ); |
| 382 | 382 | |
| 383 | 383 | // Check if there are any posted "Other" values |
| 384 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
| 384 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
| 385 | 385 | |
| 386 | 386 | // Save original value |
| 387 | 387 | $args['temp_value'] = $value; |
| 388 | 388 | $args['other'] = true; |
| 389 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 389 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); |
|
| 390 | 390 | |
| 391 | 391 | // Set the validation value now |
| 392 | 392 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -408,12 +408,12 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // Check if there are any other posted "other" values for this field |
| 411 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
| 411 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
| 412 | 412 | // Save original value |
| 413 | 413 | $args['temp_value'] = $value; |
| 414 | 414 | $args['other'] = true; |
| 415 | 415 | |
| 416 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 416 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; |
|
| 417 | 417 | |
| 418 | 418 | // Set the validation value now |
| 419 | 419 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -445,27 +445,27 @@ discard block |
||
| 445 | 445 | } |
| 446 | 446 | } else { |
| 447 | 447 | // Radio and dropdowns |
| 448 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 448 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); |
|
| 449 | 449 | $other_key = reset( $other_key ); |
| 450 | 450 | |
| 451 | 451 | // Multi-select dropdown |
| 452 | 452 | if ( is_array( $value ) ) { |
| 453 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 453 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
| 454 | 454 | |
| 455 | 455 | if ( $o_key !== false ) { |
| 456 | 456 | // Modify the original value so other key will be preserved |
| 457 | - $value[ $other_key ] = $value[ $o_key ]; |
|
| 457 | + $value[$other_key] = $value[$o_key]; |
|
| 458 | 458 | |
| 459 | 459 | // By default, the array keys will be numeric for multi-select dropdowns |
| 460 | 460 | // If going backwards and forwards between pages, the array key will match the other key |
| 461 | 461 | if ( $o_key != $other_key ) { |
| 462 | - unset( $value[ $o_key ] ); |
|
| 462 | + unset( $value[$o_key] ); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | $args['temp_value'] = $value; |
| 466 | - $value[ $other_key ] = reset( $other_vals ); |
|
| 466 | + $value[$other_key] = reset( $other_vals ); |
|
| 467 | 467 | } |
| 468 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
| 468 | + } else if ( $field->options[$other_key] == $value ) { |
|
| 469 | 469 | $value = $other_vals; |
| 470 | 470 | } |
| 471 | 471 | } |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | $content .= "\n\n"; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - if ( is_array($val) ) { |
|
| 487 | + if ( is_array( $val ) ) { |
|
| 488 | 488 | $val = FrmAppHelper::array_flatten( $val ); |
| 489 | 489 | $val = implode( ', ', $val ); |
| 490 | 490 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers |
| 549 | 549 | |
| 550 | 550 | // see how many we have |
| 551 | - $i = count($matches['browser']); |
|
| 551 | + $i = count( $matches['browser'] ); |
|
| 552 | 552 | |
| 553 | 553 | if ( $i > 1 ) { |
| 554 | 554 | //we will have two since we are not using 'other' argument yet |
@@ -12,50 +12,50 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public static $plug_version = '2.05.07'; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @since 1.07.02 |
|
| 17 | - * |
|
| 18 | - * @param none |
|
| 19 | - * @return string The version of this plugin |
|
| 20 | - */ |
|
| 21 | - public static function plugin_version() { |
|
| 22 | - return self::$plug_version; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function plugin_folder() { |
|
| 26 | - return basename(self::plugin_path()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public static function plugin_path() { |
|
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function plugin_url() { |
|
| 34 | - //prevously FRM_URL constant |
|
| 15 | + /** |
|
| 16 | + * @since 1.07.02 |
|
| 17 | + * |
|
| 18 | + * @param none |
|
| 19 | + * @return string The version of this plugin |
|
| 20 | + */ |
|
| 21 | + public static function plugin_version() { |
|
| 22 | + return self::$plug_version; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function plugin_folder() { |
|
| 26 | + return basename(self::plugin_path()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public static function plugin_path() { |
|
| 30 | + return dirname(dirname(dirname(__FILE__))); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function plugin_url() { |
|
| 34 | + //prevously FRM_URL constant |
|
| 35 | 35 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function relative_plugin_url() { |
| 39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string Site URL |
|
| 44 | - */ |
|
| 45 | - public static function site_url() { |
|
| 46 | - return site_url(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Get the name of this site |
|
| 51 | - * Used for [sitename] shortcode |
|
| 52 | - * |
|
| 53 | - * @since 2.0 |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function site_name() { |
|
| 57 | - return get_option('blogname'); |
|
| 58 | - } |
|
| 42 | + /** |
|
| 43 | + * @return string Site URL |
|
| 44 | + */ |
|
| 45 | + public static function site_url() { |
|
| 46 | + return site_url(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Get the name of this site |
|
| 51 | + * Used for [sitename] shortcode |
|
| 52 | + * |
|
| 53 | + * @since 2.0 |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function site_name() { |
|
| 57 | + return get_option('blogname'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
| 61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Get the Formidable settings |
|
| 75 | - * |
|
| 76 | - * @since 2.0 |
|
| 77 | - * |
|
| 78 | - * @param None |
|
| 79 | - * @return FrmSettings $frm_setings |
|
| 80 | - */ |
|
| 81 | - public static function get_settings() { |
|
| 82 | - global $frm_settings; |
|
| 83 | - if ( empty($frm_settings) ) { |
|
| 84 | - $frm_settings = new FrmSettings(); |
|
| 85 | - } |
|
| 86 | - return $frm_settings; |
|
| 87 | - } |
|
| 73 | + /** |
|
| 74 | + * Get the Formidable settings |
|
| 75 | + * |
|
| 76 | + * @since 2.0 |
|
| 77 | + * |
|
| 78 | + * @param None |
|
| 79 | + * @return FrmSettings $frm_setings |
|
| 80 | + */ |
|
| 81 | + public static function get_settings() { |
|
| 82 | + global $frm_settings; |
|
| 83 | + if ( empty($frm_settings) ) { |
|
| 84 | + $frm_settings = new FrmSettings(); |
|
| 85 | + } |
|
| 86 | + return $frm_settings; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | public static function get_menu_name() { |
| 90 | 90 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -99,62 +99,62 @@ discard block |
||
| 99 | 99 | return ! $frm_settings->no_ips; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Show a message in place of pro features |
|
| 104 | - * |
|
| 105 | - * @since 2.0 |
|
| 106 | - */ |
|
| 102 | + /** |
|
| 103 | + * Show a message in place of pro features |
|
| 104 | + * |
|
| 105 | + * @since 2.0 |
|
| 106 | + */ |
|
| 107 | 107 | public static function update_message() { |
| 108 | 108 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
| 109 | - } |
|
| 110 | - |
|
| 111 | - public static function pro_is_installed() { |
|
| 112 | - return apply_filters('frm_pro_installed', false); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Check for certain page in Formidable settings |
|
| 117 | - * |
|
| 118 | - * @since 2.0 |
|
| 119 | - * |
|
| 120 | - * @param string $page The name of the page to check |
|
| 121 | - * @return boolean |
|
| 122 | - */ |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public static function pro_is_installed() { |
|
| 112 | + return apply_filters('frm_pro_installed', false); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Check for certain page in Formidable settings |
|
| 117 | + * |
|
| 118 | + * @since 2.0 |
|
| 119 | + * |
|
| 120 | + * @param string $page The name of the page to check |
|
| 121 | + * @return boolean |
|
| 122 | + */ |
|
| 123 | 123 | public static function is_admin_page( $page = 'formidable' ) { |
| 124 | - global $pagenow; |
|
| 124 | + global $pagenow; |
|
| 125 | 125 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 126 | - if ( $pagenow ) { |
|
| 126 | + if ( $pagenow ) { |
|
| 127 | 127 | return $pagenow == 'admin.php' && $get_page == $page; |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | return is_admin() && $get_page == $page; |
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Check for the form preview page |
|
| 135 | - * |
|
| 136 | - * @since 2.0 |
|
| 137 | - * |
|
| 138 | - * @param None |
|
| 139 | - * @return boolean |
|
| 140 | - */ |
|
| 141 | - public static function is_preview_page() { |
|
| 142 | - global $pagenow; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Check for the form preview page |
|
| 135 | + * |
|
| 136 | + * @since 2.0 |
|
| 137 | + * |
|
| 138 | + * @param None |
|
| 139 | + * @return boolean |
|
| 140 | + */ |
|
| 141 | + public static function is_preview_page() { |
|
| 142 | + global $pagenow; |
|
| 143 | 143 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 144 | 144 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 145 | - } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Check for ajax except the form preview page |
|
| 149 | - * |
|
| 150 | - * @since 2.0 |
|
| 151 | - * |
|
| 152 | - * @param None |
|
| 153 | - * @return boolean |
|
| 154 | - */ |
|
| 155 | - public static function doing_ajax() { |
|
| 156 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 157 | - } |
|
| 147 | + /** |
|
| 148 | + * Check for ajax except the form preview page |
|
| 149 | + * |
|
| 150 | + * @since 2.0 |
|
| 151 | + * |
|
| 152 | + * @param None |
|
| 153 | + * @return boolean |
|
| 154 | + */ |
|
| 155 | + public static function doing_ajax() { |
|
| 156 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | 160 | * Use the WP 4.7 wp_doing_ajax function |
@@ -177,81 +177,81 @@ discard block |
||
| 177 | 177 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Check if on an admin page |
|
| 182 | - * |
|
| 183 | - * @since 2.0 |
|
| 184 | - * |
|
| 185 | - * @param None |
|
| 186 | - * @return boolean |
|
| 187 | - */ |
|
| 188 | - public static function is_admin() { |
|
| 189 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Check if value contains blank value or empty array |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * @param mixed $value - value to check |
|
| 180 | + /** |
|
| 181 | + * Check if on an admin page |
|
| 182 | + * |
|
| 183 | + * @since 2.0 |
|
| 184 | + * |
|
| 185 | + * @param None |
|
| 186 | + * @return boolean |
|
| 187 | + */ |
|
| 188 | + public static function is_admin() { |
|
| 189 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Check if value contains blank value or empty array |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * @param mixed $value - value to check |
|
| 197 | 197 | * @param string |
| 198 | - * @return boolean |
|
| 199 | - */ |
|
| 200 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 201 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 205 | - return ! self::is_empty_value( $value, $empty ); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Get any value from the $_SERVER |
|
| 210 | - * |
|
| 211 | - * @since 2.0 |
|
| 212 | - * @param string $value |
|
| 213 | - * @return string |
|
| 214 | - */ |
|
| 198 | + * @return boolean |
|
| 199 | + */ |
|
| 200 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 201 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 205 | + return ! self::is_empty_value( $value, $empty ); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Get any value from the $_SERVER |
|
| 210 | + * |
|
| 211 | + * @since 2.0 |
|
| 212 | + * @param string $value |
|
| 213 | + * @return string |
|
| 214 | + */ |
|
| 215 | 215 | public static function get_server_value( $value ) { |
| 216 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Check for the IP address in several places |
|
| 221 | - * Used by [ip] shortcode |
|
| 222 | - * |
|
| 223 | - * @return string The IP address of the current user |
|
| 224 | - */ |
|
| 225 | - public static function get_ip_address() { |
|
| 216 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Check for the IP address in several places |
|
| 221 | + * Used by [ip] shortcode |
|
| 222 | + * |
|
| 223 | + * @return string The IP address of the current user |
|
| 224 | + */ |
|
| 225 | + public static function get_ip_address() { |
|
| 226 | 226 | $ip = ''; |
| 227 | 227 | foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { |
| 228 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 229 | - continue; |
|
| 230 | - } |
|
| 228 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 229 | + continue; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 233 | - $ip = trim($ip); // just to be safe |
|
| 232 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 233 | + $ip = trim($ip); // just to be safe |
|
| 234 | 234 | |
| 235 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 236 | - return sanitize_text_field( $ip ); |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - } |
|
| 235 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 236 | + return sanitize_text_field( $ip ); |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | return sanitize_text_field( $ip ); |
| 242 | - } |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 245 | - if ( strpos($param, '[') ) { |
|
| 246 | - $params = explode('[', $param); |
|
| 247 | - $param = $params[0]; |
|
| 248 | - } |
|
| 244 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 245 | + if ( strpos($param, '[') ) { |
|
| 246 | + $params = explode('[', $param); |
|
| 247 | + $param = $params[0]; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | if ( $src == 'get' ) { |
| 251 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 252 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 253 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 254 | - } |
|
| 251 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 252 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 253 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 254 | + } |
|
| 255 | 255 | self::sanitize_value( $sanitize, $value ); |
| 256 | 256 | } else { |
| 257 | 257 | $value = self::get_simple_request( array( |
@@ -263,18 +263,18 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 266 | - foreach ( $params as $k => $p ) { |
|
| 267 | - if ( ! $k || ! is_array($value) ) { |
|
| 268 | - continue; |
|
| 269 | - } |
|
| 266 | + foreach ( $params as $k => $p ) { |
|
| 267 | + if ( ! $k || ! is_array($value) ) { |
|
| 268 | + continue; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - $p = trim($p, ']'); |
|
| 272 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 273 | - } |
|
| 274 | - } |
|
| 271 | + $p = trim($p, ']'); |
|
| 272 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - return $value; |
|
| 277 | - } |
|
| 276 | + return $value; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | 279 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 280 | 280 | return self::get_simple_request( array( |
@@ -338,12 +338,12 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
| 341 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 342 | - * |
|
| 343 | - * @since 2.0.8 |
|
| 344 | - * @param string $value |
|
| 345 | - * @return string $value |
|
| 346 | - */ |
|
| 341 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 342 | + * |
|
| 343 | + * @since 2.0.8 |
|
| 344 | + * @param string $value |
|
| 345 | + * @return string $value |
|
| 346 | + */ |
|
| 347 | 347 | public static function preserve_backslashes( $value ) { |
| 348 | 348 | // If backslashes have already been added, don't add them again |
| 349 | 349 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -365,14 +365,14 @@ discard block |
||
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 369 | - $temp_values = $values; |
|
| 370 | - foreach ( $temp_values as $k => $val ) { |
|
| 371 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 368 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 369 | + $temp_values = $values; |
|
| 370 | + foreach ( $temp_values as $k => $val ) { |
|
| 371 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 372 | 372 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 373 | - } |
|
| 374 | - } |
|
| 375 | - } |
|
| 373 | + } |
|
| 374 | + } |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | 377 | public static function sanitize_array( &$values ) { |
| 378 | 378 | $temp_values = $values; |
@@ -496,71 +496,71 @@ discard block |
||
| 496 | 496 | ); |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - /** |
|
| 500 | - * Used when switching the action for a bulk action |
|
| 501 | - * @since 2.0 |
|
| 502 | - */ |
|
| 503 | - public static function remove_get_action() { |
|
| 504 | - if ( ! isset($_GET) ) { |
|
| 505 | - return; |
|
| 506 | - } |
|
| 499 | + /** |
|
| 500 | + * Used when switching the action for a bulk action |
|
| 501 | + * @since 2.0 |
|
| 502 | + */ |
|
| 503 | + public static function remove_get_action() { |
|
| 504 | + if ( ! isset($_GET) ) { |
|
| 505 | + return; |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 509 | - if ( ! empty( $new_action ) ) { |
|
| 508 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 509 | + if ( ! empty( $new_action ) ) { |
|
| 510 | 510 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 511 | - } |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - /** |
|
| 515 | - * Check the WP query for a parameter |
|
| 516 | - * |
|
| 517 | - * @since 2.0 |
|
| 518 | - * @return string|array |
|
| 519 | - */ |
|
| 520 | - public static function get_query_var( $value, $param ) { |
|
| 521 | - if ( $value != '' ) { |
|
| 522 | - return $value; |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - global $wp_query; |
|
| 526 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 527 | - $value = $wp_query->query_vars[ $param ]; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return $value; |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - /** |
|
| 534 | - * @param string $type |
|
| 535 | - */ |
|
| 536 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 537 | - // only load the form hooks once |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + /** |
|
| 515 | + * Check the WP query for a parameter |
|
| 516 | + * |
|
| 517 | + * @since 2.0 |
|
| 518 | + * @return string|array |
|
| 519 | + */ |
|
| 520 | + public static function get_query_var( $value, $param ) { |
|
| 521 | + if ( $value != '' ) { |
|
| 522 | + return $value; |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + global $wp_query; |
|
| 526 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 527 | + $value = $wp_query->query_vars[ $param ]; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return $value; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + /** |
|
| 534 | + * @param string $type |
|
| 535 | + */ |
|
| 536 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 537 | + // only load the form hooks once |
|
| 538 | 538 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 539 | - if ( ! $hooks_loaded ) { |
|
| 539 | + if ( ! $hooks_loaded ) { |
|
| 540 | 540 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 541 | - } |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - /** |
|
| 545 | - * Check a value from a shortcode to see if true or false. |
|
| 546 | - * True when value is 1, true, 'true', 'yes' |
|
| 547 | - * |
|
| 548 | - * @since 1.07.10 |
|
| 549 | - * |
|
| 550 | - * @param string $value The value to compare |
|
| 551 | - * @return boolean True or False |
|
| 552 | - */ |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + /** |
|
| 545 | + * Check a value from a shortcode to see if true or false. |
|
| 546 | + * True when value is 1, true, 'true', 'yes' |
|
| 547 | + * |
|
| 548 | + * @since 1.07.10 |
|
| 549 | + * |
|
| 550 | + * @param string $value The value to compare |
|
| 551 | + * @return boolean True or False |
|
| 552 | + */ |
|
| 553 | 553 | public static function is_true( $value ) { |
| 554 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 555 | - } |
|
| 554 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - /** |
|
| 558 | - * Used to filter shortcode in text widgets |
|
| 559 | - */ |
|
| 560 | - public static function widget_text_filter_callback( $matches ) { |
|
| 557 | + /** |
|
| 558 | + * Used to filter shortcode in text widgets |
|
| 559 | + */ |
|
| 560 | + public static function widget_text_filter_callback( $matches ) { |
|
| 561 | 561 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 562 | - return do_shortcode( $matches[0] ); |
|
| 563 | - } |
|
| 562 | + return do_shortcode( $matches[0] ); |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | 565 | public static function get_pages() { |
| 566 | 566 | return get_posts( array( |
@@ -572,10 +572,10 @@ discard block |
||
| 572 | 572 | ) ); |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 576 | - $pages = self::get_pages(); |
|
| 575 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 576 | + $pages = self::get_pages(); |
|
| 577 | 577 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 578 | - ?> |
|
| 578 | + ?> |
|
| 579 | 579 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 580 | 580 | <option value=""> </option> |
| 581 | 581 | <?php foreach ( $pages as $page ) { ?> |
@@ -585,16 +585,16 @@ discard block |
||
| 585 | 585 | <?php } ?> |
| 586 | 586 | </select> |
| 587 | 587 | <?php |
| 588 | - } |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | 590 | public static function post_edit_link( $post_id ) { |
| 591 | - $post = get_post($post_id); |
|
| 592 | - if ( $post ) { |
|
| 591 | + $post = get_post($post_id); |
|
| 592 | + if ( $post ) { |
|
| 593 | 593 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 594 | 594 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 595 | - } |
|
| 596 | - return ''; |
|
| 597 | - } |
|
| 595 | + } |
|
| 596 | + return ''; |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | 599 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 600 | 600 | ?> |
@@ -605,87 +605,87 @@ discard block |
||
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | public static function roles_options( $capability ) { |
| 608 | - global $frm_vars; |
|
| 609 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 610 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 611 | - } else { |
|
| 612 | - $editable_roles = get_editable_roles(); |
|
| 613 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - foreach ( $editable_roles as $role => $details ) { |
|
| 608 | + global $frm_vars; |
|
| 609 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 610 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 611 | + } else { |
|
| 612 | + $editable_roles = get_editable_roles(); |
|
| 613 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + foreach ( $editable_roles as $role => $details ) { |
|
| 617 | 617 | $name = translate_user_role( $details['name'] ); |
| 618 | 618 | ?> |
| 619 | 619 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 620 | 620 | <?php |
| 621 | - unset($role, $details); |
|
| 622 | - } |
|
| 623 | - } |
|
| 621 | + unset($role, $details); |
|
| 622 | + } |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | 625 | public static function frm_capabilities( $type = 'auto' ) { |
| 626 | - $cap = array( |
|
| 627 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 628 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 629 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 630 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 631 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 632 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 633 | - ); |
|
| 626 | + $cap = array( |
|
| 627 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 628 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 629 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 630 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 631 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 632 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 633 | + ); |
|
| 634 | 634 | |
| 635 | 635 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 636 | - return $cap; |
|
| 637 | - } |
|
| 636 | + return $cap; |
|
| 637 | + } |
|
| 638 | 638 | |
| 639 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 640 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 641 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 642 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 639 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 640 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 641 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 642 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 643 | 643 | |
| 644 | - return $cap; |
|
| 645 | - } |
|
| 644 | + return $cap; |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | 647 | public static function user_has_permission( $needed_role ) { |
| 648 | - if ( $needed_role == '-1' ) { |
|
| 649 | - return false; |
|
| 648 | + if ( $needed_role == '-1' ) { |
|
| 649 | + return false; |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 653 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 654 | - return true; |
|
| 655 | - } |
|
| 652 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 653 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 654 | + return true; |
|
| 655 | + } |
|
| 656 | 656 | |
| 657 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 658 | - foreach ( $roles as $role ) { |
|
| 657 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 658 | + foreach ( $roles as $role ) { |
|
| 659 | 659 | if ( current_user_can( $role ) ) { |
| 660 | - return true; |
|
| 660 | + return true; |
|
| 661 | 661 | } |
| 662 | - if ( $role == $needed_role ) { |
|
| 663 | - break; |
|
| 662 | + if ( $role == $needed_role ) { |
|
| 663 | + break; |
|
| 664 | 664 | } |
| 665 | - } |
|
| 666 | - return false; |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - /** |
|
| 670 | - * Make sure administrators can see Formidable menu |
|
| 671 | - * |
|
| 672 | - * @since 2.0 |
|
| 673 | - */ |
|
| 674 | - public static function maybe_add_permissions() { |
|
| 665 | + } |
|
| 666 | + return false; |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + /** |
|
| 670 | + * Make sure administrators can see Formidable menu |
|
| 671 | + * |
|
| 672 | + * @since 2.0 |
|
| 673 | + */ |
|
| 674 | + public static function maybe_add_permissions() { |
|
| 675 | 675 | self::force_capability( 'frm_view_entries' ); |
| 676 | 676 | |
| 677 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 678 | - return; |
|
| 679 | - } |
|
| 677 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 678 | + return; |
|
| 679 | + } |
|
| 680 | 680 | |
| 681 | 681 | $user_id = get_current_user_id(); |
| 682 | 682 | $user = new WP_User( $user_id ); |
| 683 | - $frm_roles = self::frm_capabilities(); |
|
| 684 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 683 | + $frm_roles = self::frm_capabilities(); |
|
| 684 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 685 | 685 | $user->add_cap( $frm_role ); |
| 686 | - unset($frm_role, $frm_role_description); |
|
| 687 | - } |
|
| 688 | - } |
|
| 686 | + unset($frm_role, $frm_role_description); |
|
| 687 | + } |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | 690 | /** |
| 691 | 691 | * Make sure admins have permission to see the menu items |
@@ -701,28 +701,28 @@ discard block |
||
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - /** |
|
| 705 | - * Check if the user has permision for action. |
|
| 706 | - * Return permission message and stop the action if no permission |
|
| 707 | - * @since 2.0 |
|
| 708 | - * @param string $permission |
|
| 709 | - */ |
|
| 704 | + /** |
|
| 705 | + * Check if the user has permision for action. |
|
| 706 | + * Return permission message and stop the action if no permission |
|
| 707 | + * @since 2.0 |
|
| 708 | + * @param string $permission |
|
| 709 | + */ |
|
| 710 | 710 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 711 | - $permission_error = self::permission_nonce_error($permission); |
|
| 712 | - if ( $permission_error !== false ) { |
|
| 713 | - if ( 'hide' == $show_message ) { |
|
| 714 | - $permission_error = ''; |
|
| 715 | - } |
|
| 716 | - wp_die($permission_error); |
|
| 717 | - } |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - /** |
|
| 721 | - * Check user permission and nonce |
|
| 722 | - * @since 2.0 |
|
| 723 | - * @param string $permission |
|
| 724 | - * @return false|string The permission message or false if allowed |
|
| 725 | - */ |
|
| 711 | + $permission_error = self::permission_nonce_error($permission); |
|
| 712 | + if ( $permission_error !== false ) { |
|
| 713 | + if ( 'hide' == $show_message ) { |
|
| 714 | + $permission_error = ''; |
|
| 715 | + } |
|
| 716 | + wp_die($permission_error); |
|
| 717 | + } |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + /** |
|
| 721 | + * Check user permission and nonce |
|
| 722 | + * @since 2.0 |
|
| 723 | + * @param string $permission |
|
| 724 | + * @return false|string The permission message or false if allowed |
|
| 725 | + */ |
|
| 726 | 726 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 727 | 727 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 728 | 728 | $frm_settings = self::get_settings(); |
@@ -730,23 +730,23 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | $error = false; |
| 733 | - if ( empty($nonce_name) ) { |
|
| 734 | - return $error; |
|
| 735 | - } |
|
| 733 | + if ( empty($nonce_name) ) { |
|
| 734 | + return $error; |
|
| 735 | + } |
|
| 736 | 736 | |
| 737 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 738 | - $frm_settings = self::get_settings(); |
|
| 739 | - $error = $frm_settings->admin_permission; |
|
| 740 | - } |
|
| 737 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 738 | + $frm_settings = self::get_settings(); |
|
| 739 | + $error = $frm_settings->admin_permission; |
|
| 740 | + } |
|
| 741 | 741 | |
| 742 | - return $error; |
|
| 743 | - } |
|
| 742 | + return $error; |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - public static function checked( $values, $current ) { |
|
| 745 | + public static function checked( $values, $current ) { |
|
| 746 | 746 | if ( self::check_selected( $values, $current ) ) { |
| 747 | - echo ' checked="checked"'; |
|
| 747 | + echo ' checked="checked"'; |
|
| 748 | 748 | } |
| 749 | - } |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | 751 | public static function check_selected( $values, $current ) { |
| 752 | 752 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -756,50 +756,50 @@ discard block |
||
| 756 | 756 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | - /** |
|
| 760 | - * Check if current field option is an "other" option |
|
| 761 | - * |
|
| 762 | - * @since 2.0 |
|
| 763 | - * |
|
| 764 | - * @param string $opt_key |
|
| 765 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 766 | - */ |
|
| 767 | - public static function is_other_opt( $opt_key ) { |
|
| 768 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 769 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 770 | - } |
|
| 771 | - |
|
| 772 | - /** |
|
| 773 | - * Get value that belongs in "Other" text box |
|
| 774 | - * |
|
| 775 | - * @since 2.0 |
|
| 776 | - * |
|
| 777 | - * @param string $opt_key |
|
| 778 | - * @param array $field |
|
| 779 | - * @return string $other_val |
|
| 780 | - */ |
|
| 781 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 759 | + /** |
|
| 760 | + * Check if current field option is an "other" option |
|
| 761 | + * |
|
| 762 | + * @since 2.0 |
|
| 763 | + * |
|
| 764 | + * @param string $opt_key |
|
| 765 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 766 | + */ |
|
| 767 | + public static function is_other_opt( $opt_key ) { |
|
| 768 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 769 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 770 | + } |
|
| 771 | + |
|
| 772 | + /** |
|
| 773 | + * Get value that belongs in "Other" text box |
|
| 774 | + * |
|
| 775 | + * @since 2.0 |
|
| 776 | + * |
|
| 777 | + * @param string $opt_key |
|
| 778 | + * @param array $field |
|
| 779 | + * @return string $other_val |
|
| 780 | + */ |
|
| 781 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 782 | 782 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
| 783 | 783 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
| 784 | - } |
|
| 785 | - |
|
| 786 | - /** |
|
| 787 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 788 | - * Intended for front-end use |
|
| 789 | - * |
|
| 790 | - * @since 2.0 |
|
| 791 | - * |
|
| 792 | - * @param array $field |
|
| 793 | - * @param boolean $other_opt |
|
| 794 | - * @param string $checked |
|
| 795 | - * @param array $args should include opt_key and field name |
|
| 796 | - * @return string $other_val |
|
| 797 | - */ |
|
| 798 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 784 | + } |
|
| 785 | + |
|
| 786 | + /** |
|
| 787 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 788 | + * Intended for front-end use |
|
| 789 | + * |
|
| 790 | + * @since 2.0 |
|
| 791 | + * |
|
| 792 | + * @param array $field |
|
| 793 | + * @param boolean $other_opt |
|
| 794 | + * @param string $checked |
|
| 795 | + * @param array $args should include opt_key and field name |
|
| 796 | + * @return string $other_val |
|
| 797 | + */ |
|
| 798 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 799 | 799 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
| 800 | 800 | $args['field'] = $field; |
| 801 | 801 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
| 802 | - } |
|
| 802 | + } |
|
| 803 | 803 | |
| 804 | 804 | public static function recursive_function_map( $value, $function ) { |
| 805 | 805 | if ( is_array( $value ) ) { |
@@ -829,24 +829,24 @@ discard block |
||
| 829 | 829 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - /** |
|
| 833 | - * Flatten a multi-dimensional array |
|
| 834 | - */ |
|
| 832 | + /** |
|
| 833 | + * Flatten a multi-dimensional array |
|
| 834 | + */ |
|
| 835 | 835 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 836 | - $return = array(); |
|
| 837 | - foreach ( $array as $key => $value ) { |
|
| 838 | - if ( is_array($value) ) { |
|
| 836 | + $return = array(); |
|
| 837 | + foreach ( $array as $key => $value ) { |
|
| 838 | + if ( is_array($value) ) { |
|
| 839 | 839 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 840 | - } else { |
|
| 840 | + } else { |
|
| 841 | 841 | if ( $keys == 'keep' ) { |
| 842 | 842 | $return[ $key ] = $value; |
| 843 | 843 | } else { |
| 844 | 844 | $return[] = $value; |
| 845 | 845 | } |
| 846 | - } |
|
| 847 | - } |
|
| 848 | - return $return; |
|
| 849 | - } |
|
| 846 | + } |
|
| 847 | + } |
|
| 848 | + return $return; |
|
| 849 | + } |
|
| 850 | 850 | |
| 851 | 851 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 852 | 852 | $safe_text = str_replace( '"', '"', $text ); |
@@ -857,38 +857,38 @@ discard block |
||
| 857 | 857 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - /** |
|
| 861 | - * Add auto paragraphs to text areas |
|
| 862 | - * @since 2.0 |
|
| 863 | - */ |
|
| 860 | + /** |
|
| 861 | + * Add auto paragraphs to text areas |
|
| 862 | + * @since 2.0 |
|
| 863 | + */ |
|
| 864 | 864 | public static function use_wpautop( $content ) { |
| 865 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 866 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 867 | - } |
|
| 868 | - return $content; |
|
| 869 | - } |
|
| 865 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 866 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 867 | + } |
|
| 868 | + return $content; |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | 871 | public static function replace_quotes( $val ) { |
| 872 | - //Replace double quotes |
|
| 872 | + //Replace double quotes |
|
| 873 | 873 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 874 | - //Replace single quotes |
|
| 875 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 876 | - return $val; |
|
| 877 | - } |
|
| 878 | - |
|
| 879 | - /** |
|
| 880 | - * @since 2.0 |
|
| 881 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 882 | - */ |
|
| 883 | - public static function jquery_ui_base_url() { |
|
| 874 | + //Replace single quotes |
|
| 875 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 876 | + return $val; |
|
| 877 | + } |
|
| 878 | + |
|
| 879 | + /** |
|
| 880 | + * @since 2.0 |
|
| 881 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 882 | + */ |
|
| 883 | + public static function jquery_ui_base_url() { |
|
| 884 | 884 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 885 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 886 | - return $url; |
|
| 887 | - } |
|
| 885 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 886 | + return $url; |
|
| 887 | + } |
|
| 888 | 888 | |
| 889 | - /** |
|
| 890 | - * @param string $handle |
|
| 891 | - */ |
|
| 889 | + /** |
|
| 890 | + * @param string $handle |
|
| 891 | + */ |
|
| 892 | 892 | public static function script_version( $handle, $default = 0 ) { |
| 893 | 893 | global $wp_scripts; |
| 894 | 894 | if ( ! $wp_scripts ) { |
@@ -910,75 +910,75 @@ discard block |
||
| 910 | 910 | |
| 911 | 911 | public static function js_redirect( $url ) { |
| 912 | 912 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 913 | - } |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | 915 | public static function get_user_id_param( $user_id ) { |
| 916 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 917 | - return $user_id; |
|
| 918 | - } |
|
| 916 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 917 | + return $user_id; |
|
| 918 | + } |
|
| 919 | 919 | |
| 920 | 920 | $user_id = sanitize_text_field( $user_id ); |
| 921 | 921 | if ( $user_id == 'current' ) { |
| 922 | 922 | $user_id = get_current_user_id(); |
| 923 | 923 | } else { |
| 924 | - if ( is_email($user_id) ) { |
|
| 925 | - $user = get_user_by('email', $user_id); |
|
| 926 | - } else { |
|
| 927 | - $user = get_user_by('login', $user_id); |
|
| 928 | - } |
|
| 924 | + if ( is_email($user_id) ) { |
|
| 925 | + $user = get_user_by('email', $user_id); |
|
| 926 | + } else { |
|
| 927 | + $user = get_user_by('login', $user_id); |
|
| 928 | + } |
|
| 929 | 929 | |
| 930 | - if ( $user ) { |
|
| 931 | - $user_id = $user->ID; |
|
| 932 | - } |
|
| 933 | - unset($user); |
|
| 934 | - } |
|
| 930 | + if ( $user ) { |
|
| 931 | + $user_id = $user->ID; |
|
| 932 | + } |
|
| 933 | + unset($user); |
|
| 934 | + } |
|
| 935 | 935 | |
| 936 | - return $user_id; |
|
| 937 | - } |
|
| 936 | + return $user_id; |
|
| 937 | + } |
|
| 938 | 938 | |
| 939 | 939 | public static function get_file_contents( $filename, $atts = array() ) { |
| 940 | - if ( ! is_file($filename) ) { |
|
| 941 | - return false; |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - extract($atts); |
|
| 945 | - ob_start(); |
|
| 946 | - include($filename); |
|
| 947 | - $contents = ob_get_contents(); |
|
| 948 | - ob_end_clean(); |
|
| 949 | - return $contents; |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - /** |
|
| 953 | - * @param string $table_name |
|
| 954 | - * @param string $column |
|
| 940 | + if ( ! is_file($filename) ) { |
|
| 941 | + return false; |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + extract($atts); |
|
| 945 | + ob_start(); |
|
| 946 | + include($filename); |
|
| 947 | + $contents = ob_get_contents(); |
|
| 948 | + ob_end_clean(); |
|
| 949 | + return $contents; |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + /** |
|
| 953 | + * @param string $table_name |
|
| 954 | + * @param string $column |
|
| 955 | 955 | * @param int $id |
| 956 | 956 | * @param int $num_chars |
| 957 | - */ |
|
| 958 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 959 | - $key = ''; |
|
| 957 | + */ |
|
| 958 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 959 | + $key = ''; |
|
| 960 | 960 | |
| 961 | - if ( ! empty( $name ) ) { |
|
| 962 | - $key = sanitize_key($name); |
|
| 963 | - } |
|
| 961 | + if ( ! empty( $name ) ) { |
|
| 962 | + $key = sanitize_key($name); |
|
| 963 | + } |
|
| 964 | 964 | |
| 965 | 965 | if ( empty( $key ) ) { |
| 966 | - $max_slug_value = pow(36, $num_chars); |
|
| 967 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 968 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 969 | - } |
|
| 966 | + $max_slug_value = pow(36, $num_chars); |
|
| 967 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 968 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 969 | + } |
|
| 970 | 970 | |
| 971 | 971 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 972 | 972 | $key = $key . 'a'; |
| 973 | - } |
|
| 973 | + } |
|
| 974 | 974 | |
| 975 | 975 | $key_check = FrmDb::get_var( $table_name, array( |
| 976 | 976 | $column => $key, |
| 977 | 977 | 'ID !' => $id, |
| 978 | 978 | ), $column ); |
| 979 | 979 | |
| 980 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 981 | - $suffix = 2; |
|
| 980 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 981 | + $suffix = 2; |
|
| 982 | 982 | do { |
| 983 | 983 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 984 | 984 | $key_check = FrmDb::get_var( $table_name, array( |
@@ -988,23 +988,23 @@ discard block |
||
| 988 | 988 | $suffix++; |
| 989 | 989 | } while ( $key_check || is_numeric( $key_check ) ); |
| 990 | 990 | $key = $alt_post_name; |
| 991 | - } |
|
| 992 | - return $key; |
|
| 993 | - } |
|
| 994 | - |
|
| 995 | - /** |
|
| 996 | - * Editing a Form or Entry |
|
| 997 | - * @param string $table |
|
| 998 | - * @return bool|array |
|
| 999 | - */ |
|
| 1000 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1001 | - if ( ! $record ) { |
|
| 1002 | - return false; |
|
| 1003 | - } |
|
| 1004 | - |
|
| 1005 | - if ( empty($post_values) ) { |
|
| 1006 | - $post_values = stripslashes_deep($_POST); |
|
| 1007 | - } |
|
| 991 | + } |
|
| 992 | + return $key; |
|
| 993 | + } |
|
| 994 | + |
|
| 995 | + /** |
|
| 996 | + * Editing a Form or Entry |
|
| 997 | + * @param string $table |
|
| 998 | + * @return bool|array |
|
| 999 | + */ |
|
| 1000 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1001 | + if ( ! $record ) { |
|
| 1002 | + return false; |
|
| 1003 | + } |
|
| 1004 | + |
|
| 1005 | + if ( empty($post_values) ) { |
|
| 1006 | + $post_values = stripslashes_deep($_POST); |
|
| 1007 | + } |
|
| 1008 | 1008 | |
| 1009 | 1009 | $values = array( |
| 1010 | 1010 | 'id' => $record->id, |
@@ -1012,154 +1012,154 @@ discard block |
||
| 1012 | 1012 | ); |
| 1013 | 1013 | |
| 1014 | 1014 | foreach ( array( 'name', 'description' ) as $var ) { |
| 1015 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1015 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1016 | 1016 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 1017 | - unset($var, $default_val); |
|
| 1018 | - } |
|
| 1019 | - |
|
| 1020 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 1021 | - $frm_settings = self::get_settings(); |
|
| 1022 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 1023 | - |
|
| 1024 | - foreach ( (array) $fields as $field ) { |
|
| 1025 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 1026 | - if ( ! $is_form_builder ) { |
|
| 1027 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 1028 | - } |
|
| 1017 | + unset($var, $default_val); |
|
| 1018 | + } |
|
| 1019 | + |
|
| 1020 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 1021 | + $frm_settings = self::get_settings(); |
|
| 1022 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
| 1023 | + |
|
| 1024 | + foreach ( (array) $fields as $field ) { |
|
| 1025 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 1026 | + if ( ! $is_form_builder ) { |
|
| 1027 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 1028 | + } |
|
| 1029 | 1029 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 1030 | 1030 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
| 1031 | - } |
|
| 1031 | + } |
|
| 1032 | 1032 | |
| 1033 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1033 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1034 | 1034 | |
| 1035 | - if ( $table == 'entries' ) { |
|
| 1036 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1037 | - } else if ( $table == 'forms' ) { |
|
| 1038 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1039 | - } |
|
| 1035 | + if ( $table == 'entries' ) { |
|
| 1036 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1037 | + } else if ( $table == 'forms' ) { |
|
| 1038 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1039 | + } |
|
| 1040 | 1040 | |
| 1041 | - return $values; |
|
| 1042 | - } |
|
| 1041 | + return $values; |
|
| 1042 | + } |
|
| 1043 | 1043 | |
| 1044 | 1044 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1045 | - $post_values = $args['post_values']; |
|
| 1046 | - |
|
| 1047 | - if ( $args['default'] ) { |
|
| 1048 | - $meta_value = $field->default_value; |
|
| 1049 | - } else { |
|
| 1050 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1051 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1052 | - $field->field_options['custom_field'] = ''; |
|
| 1053 | - } |
|
| 1045 | + $post_values = $args['post_values']; |
|
| 1046 | + |
|
| 1047 | + if ( $args['default'] ) { |
|
| 1048 | + $meta_value = $field->default_value; |
|
| 1049 | + } else { |
|
| 1050 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1051 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1052 | + $field->field_options['custom_field'] = ''; |
|
| 1053 | + } |
|
| 1054 | 1054 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( |
| 1055 | 1055 | 'truncate' => false, |
| 1056 | 1056 | 'type' => $field->type, |
| 1057 | 1057 | 'form_id' => $field->form_id, |
| 1058 | 1058 | 'field' => $field, |
| 1059 | 1059 | ) ); |
| 1060 | - } else { |
|
| 1060 | + } else { |
|
| 1061 | 1061 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1062 | - } |
|
| 1063 | - } |
|
| 1062 | + } |
|
| 1063 | + } |
|
| 1064 | 1064 | |
| 1065 | 1065 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1066 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1067 | - |
|
| 1068 | - $field_array = array( |
|
| 1069 | - 'id' => $field->id, |
|
| 1070 | - 'value' => $new_value, |
|
| 1071 | - 'default_value' => $field->default_value, |
|
| 1072 | - 'name' => $field->name, |
|
| 1073 | - 'description' => $field->description, |
|
| 1074 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1075 | - 'options' => $field->options, |
|
| 1076 | - 'required' => $field->required, |
|
| 1077 | - 'field_key' => $field->field_key, |
|
| 1078 | - 'field_order' => $field->field_order, |
|
| 1079 | - 'form_id' => $field->form_id, |
|
| 1066 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1067 | + |
|
| 1068 | + $field_array = array( |
|
| 1069 | + 'id' => $field->id, |
|
| 1070 | + 'value' => $new_value, |
|
| 1071 | + 'default_value' => $field->default_value, |
|
| 1072 | + 'name' => $field->name, |
|
| 1073 | + 'description' => $field->description, |
|
| 1074 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1075 | + 'options' => $field->options, |
|
| 1076 | + 'required' => $field->required, |
|
| 1077 | + 'field_key' => $field->field_key, |
|
| 1078 | + 'field_order' => $field->field_order, |
|
| 1079 | + 'form_id' => $field->form_id, |
|
| 1080 | 1080 | 'parent_form_id' => $args['parent_form_id'], |
| 1081 | - ); |
|
| 1081 | + ); |
|
| 1082 | 1082 | |
| 1083 | - $args['field_type'] = $field_type; |
|
| 1084 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1083 | + $args['field_type'] = $field_type; |
|
| 1084 | + self::fill_field_opts($field, $field_array, $args); |
|
| 1085 | 1085 | // Track the original field's type |
| 1086 | 1086 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1087 | 1087 | |
| 1088 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1088 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1089 | 1089 | |
| 1090 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1091 | - $field_array['unique_msg'] = ''; |
|
| 1092 | - } |
|
| 1090 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1091 | + $field_array['unique_msg'] = ''; |
|
| 1092 | + } |
|
| 1093 | 1093 | |
| 1094 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1094 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1095 | 1095 | |
| 1096 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1097 | - } |
|
| 1096 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1097 | + } |
|
| 1098 | 1098 | |
| 1099 | 1099 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1100 | - $post_values = $args['post_values']; |
|
| 1101 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1100 | + $post_values = $args['post_values']; |
|
| 1101 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1102 | 1102 | |
| 1103 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1103 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1104 | 1104 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
| 1105 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1106 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1107 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1108 | - if ( $args['field_type'] == 'captcha' ) { |
|
| 1109 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1110 | - } else { |
|
| 1111 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1112 | - } |
|
| 1113 | - } |
|
| 1114 | - } |
|
| 1115 | - |
|
| 1116 | - if ( $field_array['custom_html'] == '' ) { |
|
| 1117 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1118 | - } |
|
| 1119 | - } |
|
| 1120 | - |
|
| 1121 | - /** |
|
| 1122 | - * @param string $table |
|
| 1123 | - */ |
|
| 1105 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1106 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1107 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1108 | + if ( $args['field_type'] == 'captcha' ) { |
|
| 1109 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1110 | + } else { |
|
| 1111 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1112 | + } |
|
| 1113 | + } |
|
| 1114 | + } |
|
| 1115 | + |
|
| 1116 | + if ( $field_array['custom_html'] == '' ) { |
|
| 1117 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1118 | + } |
|
| 1119 | + } |
|
| 1120 | + |
|
| 1121 | + /** |
|
| 1122 | + * @param string $table |
|
| 1123 | + */ |
|
| 1124 | 1124 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1125 | - if ( $table == 'entries' ) { |
|
| 1126 | - $form = $record->form_id; |
|
| 1125 | + if ( $table == 'entries' ) { |
|
| 1126 | + $form = $record->form_id; |
|
| 1127 | 1127 | FrmForm::maybe_get_form( $form ); |
| 1128 | - } else { |
|
| 1129 | - $form = $record; |
|
| 1130 | - } |
|
| 1128 | + } else { |
|
| 1129 | + $form = $record; |
|
| 1130 | + } |
|
| 1131 | 1131 | |
| 1132 | - if ( ! $form ) { |
|
| 1133 | - return; |
|
| 1134 | - } |
|
| 1132 | + if ( ! $form ) { |
|
| 1133 | + return; |
|
| 1134 | + } |
|
| 1135 | 1135 | |
| 1136 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1136 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1137 | 1137 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1138 | 1138 | |
| 1139 | - if ( ! is_array($form->options) ) { |
|
| 1140 | - return; |
|
| 1141 | - } |
|
| 1139 | + if ( ! is_array($form->options) ) { |
|
| 1140 | + return; |
|
| 1141 | + } |
|
| 1142 | 1142 | |
| 1143 | - foreach ( $form->options as $opt => $value ) { |
|
| 1144 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1145 | - } |
|
| 1143 | + foreach ( $form->options as $opt => $value ) { |
|
| 1144 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1145 | + } |
|
| 1146 | 1146 | |
| 1147 | - self::fill_form_defaults($post_values, $values); |
|
| 1148 | - } |
|
| 1147 | + self::fill_form_defaults($post_values, $values); |
|
| 1148 | + } |
|
| 1149 | 1149 | |
| 1150 | - /** |
|
| 1151 | - * Set to POST value or default |
|
| 1152 | - */ |
|
| 1150 | + /** |
|
| 1151 | + * Set to POST value or default |
|
| 1152 | + */ |
|
| 1153 | 1153 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1154 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1154 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1155 | 1155 | |
| 1156 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1157 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1156 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1157 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1158 | 1158 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1159 | - } |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | - unset($opt, $defaut); |
|
| 1162 | - } |
|
| 1161 | + unset($opt, $defaut); |
|
| 1162 | + } |
|
| 1163 | 1163 | |
| 1164 | 1164 | if ( ! isset( $values['custom_style'] ) ) { |
| 1165 | 1165 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1168,10 +1168,10 @@ discard block |
||
| 1168 | 1168 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1169 | 1169 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1170 | 1170 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1171 | - } |
|
| 1172 | - unset($h); |
|
| 1173 | - } |
|
| 1174 | - } |
|
| 1171 | + } |
|
| 1172 | + unset($h); |
|
| 1173 | + } |
|
| 1174 | + } |
|
| 1175 | 1175 | |
| 1176 | 1176 | /** |
| 1177 | 1177 | * @since 2.2.10 |
@@ -1194,59 +1194,59 @@ discard block |
||
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | public static function insert_opt_html( $args ) { |
| 1197 | - $class = ''; |
|
| 1198 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1199 | - $class .= 'show_frm_not_email_to'; |
|
| 1200 | - } |
|
| 1201 | - ?> |
|
| 1197 | + $class = ''; |
|
| 1198 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1199 | + $class .= 'show_frm_not_email_to'; |
|
| 1200 | + } |
|
| 1201 | + ?> |
|
| 1202 | 1202 | <li> |
| 1203 | 1203 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
| 1204 | 1204 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
| 1205 | 1205 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
| 1206 | 1206 | </li> |
| 1207 | 1207 | <?php |
| 1208 | - } |
|
| 1208 | + } |
|
| 1209 | 1209 | |
| 1210 | 1210 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1211 | - if ( is_array( $str ) ) { |
|
| 1212 | - return ''; |
|
| 1211 | + if ( is_array( $str ) ) { |
|
| 1212 | + return ''; |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | - $length = (int) $length; |
|
| 1215 | + $length = (int) $length; |
|
| 1216 | 1216 | $str = wp_strip_all_tags( $str ); |
| 1217 | 1217 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1218 | 1218 | |
| 1219 | 1219 | if ( $length == 0 ) { |
| 1220 | - return ''; |
|
| 1221 | - } else if ( $length <= 10 ) { |
|
| 1220 | + return ''; |
|
| 1221 | + } else if ( $length <= 10 ) { |
|
| 1222 | 1222 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1223 | 1223 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1224 | - } |
|
| 1224 | + } |
|
| 1225 | 1225 | |
| 1226 | - $sub = ''; |
|
| 1227 | - $len = 0; |
|
| 1226 | + $sub = ''; |
|
| 1227 | + $len = 0; |
|
| 1228 | 1228 | |
| 1229 | 1229 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1230 | 1230 | |
| 1231 | 1231 | foreach ( $words as $word ) { |
| 1232 | 1232 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1233 | 1233 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1234 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1235 | - break; |
|
| 1236 | - } |
|
| 1234 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1235 | + break; |
|
| 1236 | + } |
|
| 1237 | 1237 | |
| 1238 | - $sub .= $part; |
|
| 1238 | + $sub .= $part; |
|
| 1239 | 1239 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1240 | 1240 | |
| 1241 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1242 | - break; |
|
| 1243 | - } |
|
| 1241 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1242 | + break; |
|
| 1243 | + } |
|
| 1244 | 1244 | |
| 1245 | - unset($total_len, $word); |
|
| 1246 | - } |
|
| 1245 | + unset($total_len, $word); |
|
| 1246 | + } |
|
| 1247 | 1247 | |
| 1248 | 1248 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1249 | - } |
|
| 1249 | + } |
|
| 1250 | 1250 | |
| 1251 | 1251 | public static function mb_function( $function_names, $args ) { |
| 1252 | 1252 | $mb_function_name = $function_names[0]; |
@@ -1258,18 +1258,18 @@ discard block |
||
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | 1260 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1261 | - if ( empty($date) ) { |
|
| 1262 | - return $date; |
|
| 1263 | - } |
|
| 1261 | + if ( empty($date) ) { |
|
| 1262 | + return $date; |
|
| 1263 | + } |
|
| 1264 | 1264 | |
| 1265 | - if ( empty($date_format) ) { |
|
| 1266 | - $date_format = get_option('date_format'); |
|
| 1267 | - } |
|
| 1265 | + if ( empty($date_format) ) { |
|
| 1266 | + $date_format = get_option('date_format'); |
|
| 1267 | + } |
|
| 1268 | 1268 | |
| 1269 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1270 | - $frmpro_settings = new FrmProSettings(); |
|
| 1271 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1272 | - } |
|
| 1269 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1270 | + $frmpro_settings = new FrmProSettings(); |
|
| 1271 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1272 | + } |
|
| 1273 | 1273 | |
| 1274 | 1274 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1275 | 1275 | |
@@ -1278,8 +1278,8 @@ discard block |
||
| 1278 | 1278 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | - return $formatted; |
|
| 1282 | - } |
|
| 1281 | + return $formatted; |
|
| 1282 | + } |
|
| 1283 | 1283 | |
| 1284 | 1284 | private static function add_time_to_date( $time_format, $date ) { |
| 1285 | 1285 | if ( empty( $time_format ) ) { |
@@ -1361,119 +1361,119 @@ discard block |
||
| 1361 | 1361 | ); |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | - // Pagination Methods |
|
| 1364 | + // Pagination Methods |
|
| 1365 | 1365 | |
| 1366 | - /** |
|
| 1367 | - * @param integer $current_p |
|
| 1368 | - */ |
|
| 1366 | + /** |
|
| 1367 | + * @param integer $current_p |
|
| 1368 | + */ |
|
| 1369 | 1369 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1370 | 1370 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | - /** |
|
| 1374 | - * @param integer $current_p |
|
| 1375 | - */ |
|
| 1376 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1377 | - if ( $current_p == 1 ) { |
|
| 1378 | - return 1; |
|
| 1379 | - } else { |
|
| 1380 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1381 | - } |
|
| 1382 | - } |
|
| 1373 | + /** |
|
| 1374 | + * @param integer $current_p |
|
| 1375 | + */ |
|
| 1376 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1377 | + if ( $current_p == 1 ) { |
|
| 1378 | + return 1; |
|
| 1379 | + } else { |
|
| 1380 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1381 | + } |
|
| 1382 | + } |
|
| 1383 | 1383 | |
| 1384 | 1384 | /** |
| 1385 | 1385 | * @return array |
| 1386 | 1386 | */ |
| 1387 | 1387 | public static function json_to_array( $json_vars ) { |
| 1388 | - $vars = array(); |
|
| 1389 | - foreach ( $json_vars as $jv ) { |
|
| 1390 | - $jv_name = explode('[', $jv['name']); |
|
| 1391 | - $last = count($jv_name) - 1; |
|
| 1392 | - foreach ( $jv_name as $p => $n ) { |
|
| 1393 | - $name = trim($n, ']'); |
|
| 1394 | - if ( ! isset($l1) ) { |
|
| 1395 | - $l1 = $name; |
|
| 1396 | - } |
|
| 1397 | - |
|
| 1398 | - if ( ! isset($l2) ) { |
|
| 1399 | - $l2 = $name; |
|
| 1400 | - } |
|
| 1401 | - |
|
| 1402 | - if ( ! isset($l3) ) { |
|
| 1403 | - $l3 = $name; |
|
| 1404 | - } |
|
| 1405 | - |
|
| 1406 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1407 | - |
|
| 1408 | - switch ( $p ) { |
|
| 1409 | - case 0: |
|
| 1410 | - $l1 = $name; |
|
| 1411 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1388 | + $vars = array(); |
|
| 1389 | + foreach ( $json_vars as $jv ) { |
|
| 1390 | + $jv_name = explode('[', $jv['name']); |
|
| 1391 | + $last = count($jv_name) - 1; |
|
| 1392 | + foreach ( $jv_name as $p => $n ) { |
|
| 1393 | + $name = trim($n, ']'); |
|
| 1394 | + if ( ! isset($l1) ) { |
|
| 1395 | + $l1 = $name; |
|
| 1396 | + } |
|
| 1397 | + |
|
| 1398 | + if ( ! isset($l2) ) { |
|
| 1399 | + $l2 = $name; |
|
| 1400 | + } |
|
| 1401 | + |
|
| 1402 | + if ( ! isset($l3) ) { |
|
| 1403 | + $l3 = $name; |
|
| 1404 | + } |
|
| 1405 | + |
|
| 1406 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1407 | + |
|
| 1408 | + switch ( $p ) { |
|
| 1409 | + case 0: |
|
| 1410 | + $l1 = $name; |
|
| 1411 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1412 | 1412 | break; |
| 1413 | 1413 | |
| 1414 | - case 1: |
|
| 1415 | - $l2 = $name; |
|
| 1416 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1414 | + case 1: |
|
| 1415 | + $l2 = $name; |
|
| 1416 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1417 | 1417 | break; |
| 1418 | 1418 | |
| 1419 | - case 2: |
|
| 1420 | - $l3 = $name; |
|
| 1421 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1419 | + case 2: |
|
| 1420 | + $l3 = $name; |
|
| 1421 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1422 | 1422 | break; |
| 1423 | 1423 | |
| 1424 | - case 3: |
|
| 1425 | - $l4 = $name; |
|
| 1426 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1427 | - } |
|
| 1424 | + case 3: |
|
| 1425 | + $l4 = $name; |
|
| 1426 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1427 | + } |
|
| 1428 | 1428 | |
| 1429 | - unset($this_val, $n); |
|
| 1430 | - } |
|
| 1429 | + unset($this_val, $n); |
|
| 1430 | + } |
|
| 1431 | 1431 | |
| 1432 | - unset($last, $jv); |
|
| 1433 | - } |
|
| 1432 | + unset($last, $jv); |
|
| 1433 | + } |
|
| 1434 | 1434 | |
| 1435 | - return $vars; |
|
| 1436 | - } |
|
| 1435 | + return $vars; |
|
| 1436 | + } |
|
| 1437 | 1437 | |
| 1438 | - /** |
|
| 1439 | - * @param string $name |
|
| 1440 | - * @param string $l1 |
|
| 1441 | - */ |
|
| 1442 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1443 | - if ( $name == '' ) { |
|
| 1444 | - $vars[] = $val; |
|
| 1445 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1446 | - $vars[ $l1 ] = $val; |
|
| 1447 | - } |
|
| 1448 | - } |
|
| 1438 | + /** |
|
| 1439 | + * @param string $name |
|
| 1440 | + * @param string $l1 |
|
| 1441 | + */ |
|
| 1442 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1443 | + if ( $name == '' ) { |
|
| 1444 | + $vars[] = $val; |
|
| 1445 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1446 | + $vars[ $l1 ] = $val; |
|
| 1447 | + } |
|
| 1448 | + } |
|
| 1449 | 1449 | |
| 1450 | 1450 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1451 | - $tooltips = array( |
|
| 1452 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1453 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1454 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1455 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1456 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1457 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1458 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1459 | - ); |
|
| 1460 | - |
|
| 1461 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1462 | - return; |
|
| 1463 | - } |
|
| 1464 | - |
|
| 1465 | - if ( 'open' == $class ) { |
|
| 1466 | - echo ' frm_help"'; |
|
| 1467 | - } else { |
|
| 1468 | - echo ' class="frm_help"'; |
|
| 1469 | - } |
|
| 1451 | + $tooltips = array( |
|
| 1452 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1453 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1454 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1455 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1456 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1457 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1458 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1459 | + ); |
|
| 1460 | + |
|
| 1461 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1462 | + return; |
|
| 1463 | + } |
|
| 1464 | + |
|
| 1465 | + if ( 'open' == $class ) { |
|
| 1466 | + echo ' frm_help"'; |
|
| 1467 | + } else { |
|
| 1468 | + echo ' class="frm_help"'; |
|
| 1469 | + } |
|
| 1470 | 1470 | |
| 1471 | 1471 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1472 | 1472 | |
| 1473 | - if ( 'open' != $class ) { |
|
| 1474 | - echo '"'; |
|
| 1475 | - } |
|
| 1476 | - } |
|
| 1473 | + if ( 'open' != $class ) { |
|
| 1474 | + echo '"'; |
|
| 1475 | + } |
|
| 1476 | + } |
|
| 1477 | 1477 | |
| 1478 | 1478 | /** |
| 1479 | 1479 | * Add the current_page class to that page in the form nav |
@@ -1489,35 +1489,35 @@ discard block |
||
| 1489 | 1489 | } |
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | - /** |
|
| 1493 | - * Prepare and json_encode post content |
|
| 1494 | - * |
|
| 1495 | - * @since 2.0 |
|
| 1496 | - * |
|
| 1497 | - * @param array $post_content |
|
| 1498 | - * @return string $post_content ( json encoded array ) |
|
| 1499 | - */ |
|
| 1500 | - public static function prepare_and_encode( $post_content ) { |
|
| 1501 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1492 | + /** |
|
| 1493 | + * Prepare and json_encode post content |
|
| 1494 | + * |
|
| 1495 | + * @since 2.0 |
|
| 1496 | + * |
|
| 1497 | + * @param array $post_content |
|
| 1498 | + * @return string $post_content ( json encoded array ) |
|
| 1499 | + */ |
|
| 1500 | + public static function prepare_and_encode( $post_content ) { |
|
| 1501 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1502 | 1502 | foreach ( $post_content as $key => $val ) { |
| 1503 | 1503 | // Replace problematic characters (like ") |
| 1504 | 1504 | $val = str_replace( '"', '"', $val ); |
| 1505 | 1505 | |
| 1506 | 1506 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1507 | - unset( $key, $val ); |
|
| 1508 | - } |
|
| 1507 | + unset( $key, $val ); |
|
| 1508 | + } |
|
| 1509 | 1509 | |
| 1510 | - // json_encode the array |
|
| 1511 | - $post_content = json_encode( $post_content ); |
|
| 1510 | + // json_encode the array |
|
| 1511 | + $post_content = json_encode( $post_content ); |
|
| 1512 | 1512 | |
| 1513 | - // add extra slashes for \r\n since WP strips them |
|
| 1513 | + // add extra slashes for \r\n since WP strips them |
|
| 1514 | 1514 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1515 | 1515 | |
| 1516 | - // allow for " |
|
| 1517 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1516 | + // allow for " |
|
| 1517 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1518 | 1518 | |
| 1519 | - return $post_content; |
|
| 1520 | - } |
|
| 1519 | + return $post_content; |
|
| 1520 | + } |
|
| 1521 | 1521 | |
| 1522 | 1522 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1523 | 1523 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1539,64 +1539,64 @@ discard block |
||
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | public static function maybe_json_decode( $string ) { |
| 1542 | - if ( is_array($string) ) { |
|
| 1543 | - return $string; |
|
| 1544 | - } |
|
| 1542 | + if ( is_array($string) ) { |
|
| 1543 | + return $string; |
|
| 1544 | + } |
|
| 1545 | 1545 | |
| 1546 | - $new_string = json_decode($string, true); |
|
| 1547 | - if ( function_exists('json_last_error') ) { |
|
| 1546 | + $new_string = json_decode($string, true); |
|
| 1547 | + if ( function_exists('json_last_error') ) { |
|
| 1548 | 1548 | // php 5.3+ |
| 1549 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1550 | - $string = $new_string; |
|
| 1551 | - } |
|
| 1552 | - } else if ( isset($new_string) ) { |
|
| 1549 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1550 | + $string = $new_string; |
|
| 1551 | + } |
|
| 1552 | + } else if ( isset($new_string) ) { |
|
| 1553 | 1553 | // php < 5.3 fallback |
| 1554 | - $string = $new_string; |
|
| 1555 | - } |
|
| 1556 | - return $string; |
|
| 1557 | - } |
|
| 1558 | - |
|
| 1559 | - /** |
|
| 1560 | - * @since 1.07.10 |
|
| 1561 | - * |
|
| 1562 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1563 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1564 | - */ |
|
| 1554 | + $string = $new_string; |
|
| 1555 | + } |
|
| 1556 | + return $string; |
|
| 1557 | + } |
|
| 1558 | + |
|
| 1559 | + /** |
|
| 1560 | + * @since 1.07.10 |
|
| 1561 | + * |
|
| 1562 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1563 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1564 | + */ |
|
| 1565 | 1565 | public static function maybe_highlight_menu( $post_type ) { |
| 1566 | - global $post; |
|
| 1566 | + global $post; |
|
| 1567 | 1567 | |
| 1568 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1569 | - return; |
|
| 1570 | - } |
|
| 1568 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1569 | + return; |
|
| 1570 | + } |
|
| 1571 | 1571 | |
| 1572 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1573 | - return; |
|
| 1574 | - } |
|
| 1572 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1573 | + return; |
|
| 1574 | + } |
|
| 1575 | 1575 | |
| 1576 | - self::load_admin_wide_js(); |
|
| 1577 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1578 | - } |
|
| 1576 | + self::load_admin_wide_js(); |
|
| 1577 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1578 | + } |
|
| 1579 | 1579 | |
| 1580 | - /** |
|
| 1581 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1582 | - * @since 2.0 |
|
| 1583 | - */ |
|
| 1580 | + /** |
|
| 1581 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1582 | + * @since 2.0 |
|
| 1583 | + */ |
|
| 1584 | 1584 | public static function load_admin_wide_js( $load = true ) { |
| 1585 | - $version = FrmAppHelper::plugin_version(); |
|
| 1585 | + $version = FrmAppHelper::plugin_version(); |
|
| 1586 | 1586 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1587 | 1587 | |
| 1588 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1588 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1589 | 1589 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1590 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1590 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1591 | 1591 | 'url' => FrmAppHelper::plugin_url(), |
| 1592 | 1592 | 'loading' => __( 'Loading…' ), |
| 1593 | 1593 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1594 | - ) ); |
|
| 1594 | + ) ); |
|
| 1595 | 1595 | |
| 1596 | 1596 | if ( $load ) { |
| 1597 | 1597 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1598 | 1598 | } |
| 1599 | - } |
|
| 1599 | + } |
|
| 1600 | 1600 | |
| 1601 | 1601 | /** |
| 1602 | 1602 | * @since 2.0.9 |
@@ -1605,9 +1605,9 @@ discard block |
||
| 1605 | 1605 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1606 | 1606 | } |
| 1607 | 1607 | |
| 1608 | - /** |
|
| 1609 | - * @param string $location |
|
| 1610 | - */ |
|
| 1608 | + /** |
|
| 1609 | + * @param string $location |
|
| 1610 | + */ |
|
| 1611 | 1611 | public static function localize_script( $location ) { |
| 1612 | 1612 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1613 | 1613 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1663,27 +1663,27 @@ discard block |
||
| 1663 | 1663 | } |
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | - /** |
|
| 1666 | + /** |
|
| 1667 | 1667 | * echo the message on the plugins listing page |
| 1668 | - * @since 1.07.10 |
|
| 1669 | - * |
|
| 1670 | - * @param float $min_version The version the add-on requires |
|
| 1671 | - */ |
|
| 1668 | + * @since 1.07.10 |
|
| 1669 | + * |
|
| 1670 | + * @param float $min_version The version the add-on requires |
|
| 1671 | + */ |
|
| 1672 | 1672 | public static function min_version_notice( $min_version ) { |
| 1673 | - $frm_version = self::plugin_version(); |
|
| 1673 | + $frm_version = self::plugin_version(); |
|
| 1674 | 1674 | |
| 1675 | - // check if Formidable meets minimum requirements |
|
| 1676 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1677 | - return; |
|
| 1678 | - } |
|
| 1675 | + // check if Formidable meets minimum requirements |
|
| 1676 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1677 | + return; |
|
| 1678 | + } |
|
| 1679 | 1679 | |
| 1680 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1680 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1681 | 1681 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1682 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1683 | - '</div></td></tr>'; |
|
| 1684 | - } |
|
| 1682 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1683 | + '</div></td></tr>'; |
|
| 1684 | + } |
|
| 1685 | 1685 | |
| 1686 | - public static function locales( $type = 'date' ) { |
|
| 1686 | + public static function locales( $type = 'date' ) { |
|
| 1687 | 1687 | $locales = array( |
| 1688 | 1688 | 'en' => __( 'English', 'formidable' ), |
| 1689 | 1689 | '' => __( 'English/Western', 'formidable' ), |
@@ -1758,11 +1758,11 @@ discard block |
||
| 1758 | 1758 | $unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' ); |
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1762 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1761 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1762 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1763 | 1763 | |
| 1764 | - return $locales; |
|
| 1765 | - } |
|
| 1764 | + return $locales; |
|
| 1765 | + } |
|
| 1766 | 1766 | |
| 1767 | 1767 | /** |
| 1768 | 1768 | * Prepare and save settings in styles and actions |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function plugin_folder() { |
| 26 | - return basename(self::plugin_path()); |
|
| 26 | + return basename( self::plugin_path() ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public static function plugin_path() { |
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public static function plugin_url() { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | 56 | public static function site_name() { |
| 57 | - return get_option('blogname'); |
|
| 57 | + return get_option( 'blogname' ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public static function get_settings() { |
| 82 | 82 | global $frm_settings; |
| 83 | - if ( empty($frm_settings) ) { |
|
| 83 | + if ( empty( $frm_settings ) ) { |
|
| 84 | 84 | $frm_settings = new FrmSettings(); |
| 85 | 85 | } |
| 86 | 86 | return $frm_settings; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | public static function pro_is_installed() { |
| 112 | - return apply_filters('frm_pro_installed', false); |
|
| 112 | + return apply_filters( 'frm_pro_installed', false ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | if ( function_exists( 'wp_doing_ajax' ) ) { |
| 165 | 165 | $doing_ajax = wp_doing_ajax(); |
| 166 | 166 | } else { |
| 167 | - $doing_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 167 | + $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 168 | 168 | } |
| 169 | 169 | return $doing_ajax; |
| 170 | 170 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @return string |
| 214 | 214 | */ |
| 215 | 215 | public static function get_server_value( $value ) { |
| 216 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 216 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -225,14 +225,14 @@ discard block |
||
| 225 | 225 | public static function get_ip_address() { |
| 226 | 226 | $ip = ''; |
| 227 | 227 | foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { |
| 228 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 228 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
| 229 | 229 | continue; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 233 | - $ip = trim($ip); // just to be safe |
|
| 232 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
| 233 | + $ip = trim( $ip ); // just to be safe |
|
| 234 | 234 | |
| 235 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 235 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
| 236 | 236 | return sanitize_text_field( $ip ); |
| 237 | 237 | } |
| 238 | 238 | } |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
| 245 | - if ( strpos($param, '[') ) { |
|
| 246 | - $params = explode('[', $param); |
|
| 245 | + if ( strpos( $param, '[' ) ) { |
|
| 246 | + $params = explode( '[', $param ); |
|
| 247 | 247 | $param = $params[0]; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | if ( $src == 'get' ) { |
| 251 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 252 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 253 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 251 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
| 252 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
| 253 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) ); |
|
| 254 | 254 | } |
| 255 | 255 | self::sanitize_value( $sanitize, $value ); |
| 256 | 256 | } else { |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 266 | 266 | foreach ( $params as $k => $p ) { |
| 267 | - if ( ! $k || ! is_array($value) ) { |
|
| 267 | + if ( ! $k || ! is_array( $value ) ) { |
|
| 268 | 268 | continue; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - $p = trim($p, ']'); |
|
| 272 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 271 | + $p = trim( $p, ']' ); |
|
| 272 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
@@ -320,16 +320,16 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | $value = $args['default']; |
| 322 | 322 | if ( $args['type'] == 'get' ) { |
| 323 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
| 324 | - $value = $_GET[ $args['param'] ]; |
|
| 323 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
| 324 | + $value = $_GET[$args['param']]; |
|
| 325 | 325 | } |
| 326 | 326 | } else if ( $args['type'] == 'post' ) { |
| 327 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
| 328 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
| 327 | + if ( isset( $_POST[$args['param']] ) ) { |
|
| 328 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
| 329 | 329 | } |
| 330 | 330 | } else { |
| 331 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
| 332 | - $value = $_REQUEST[ $args['param'] ]; |
|
| 331 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
| 332 | + $value = $_REQUEST[$args['param']]; |
|
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | if ( is_array( $value ) ) { |
| 358 | 358 | $temp_values = $value; |
| 359 | 359 | foreach ( $temp_values as $k => $v ) { |
| 360 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
| 360 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
| 361 | 361 | } |
| 362 | 362 | } else { |
| 363 | 363 | $value = call_user_func( $sanitize, $value ); |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 369 | 369 | $temp_values = $values; |
| 370 | 370 | foreach ( $temp_values as $k => $val ) { |
| 371 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 372 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
| 371 | + if ( isset( $sanitize_method[$k] ) ) { |
|
| 372 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | public static function sanitize_array( &$values ) { |
| 378 | 378 | $temp_values = $values; |
| 379 | 379 | foreach ( $temp_values as $k => $val ) { |
| 380 | - $values[ $k ] = wp_kses_post( $val ); |
|
| 380 | + $values[$k] = wp_kses_post( $val ); |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $allowed_html = $html; |
| 405 | 405 | } else { |
| 406 | 406 | foreach ( $allowed as $a ) { |
| 407 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
| 407 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | * @since 2.0 |
| 502 | 502 | */ |
| 503 | 503 | public static function remove_get_action() { |
| 504 | - if ( ! isset($_GET) ) { |
|
| 504 | + if ( ! isset( $_GET ) ) { |
|
| 505 | 505 | return; |
| 506 | 506 | } |
| 507 | 507 | |
@@ -523,8 +523,8 @@ discard block |
||
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | global $wp_query; |
| 526 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 527 | - $value = $wp_query->query_vars[ $param ]; |
|
| 526 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
| 527 | + $value = $wp_query->query_vars[$param]; |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | return $value; |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | return get_posts( array( |
| 567 | 567 | 'post_type' => 'page', |
| 568 | 568 | 'post_status' => array( 'publish', 'private' ), |
| 569 | - 'numberposts' => -1, |
|
| 569 | + 'numberposts' => - 1, |
|
| 570 | 570 | 'orderby' => 'title', |
| 571 | 571 | 'order' => 'ASC', |
| 572 | 572 | ) ); |
@@ -576,10 +576,10 @@ discard block |
||
| 576 | 576 | $pages = self::get_pages(); |
| 577 | 577 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 578 | 578 | ?> |
| 579 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
| 579 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
| 580 | 580 | <option value=""> </option> |
| 581 | 581 | <?php foreach ( $pages as $page ) { ?> |
| 582 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 582 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 583 | 583 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
| 584 | 584 | </option> |
| 585 | 585 | <?php } ?> |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | public static function post_edit_link( $post_id ) { |
| 591 | - $post = get_post($post_id); |
|
| 591 | + $post = get_post( $post_id ); |
|
| 592 | 592 | if ( $post ) { |
| 593 | 593 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 594 | 594 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 600 | 600 | ?> |
| 601 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect"> |
|
| 601 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect"> |
|
| 602 | 602 | <?php self::roles_options( $capability ); ?> |
| 603 | 603 | </select> |
| 604 | 604 | <?php |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | public static function roles_options( $capability ) { |
| 608 | 608 | global $frm_vars; |
| 609 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 609 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
| 610 | 610 | $editable_roles = $frm_vars['editable_roles']; |
| 611 | 611 | } else { |
| 612 | 612 | $editable_roles = get_editable_roles(); |
@@ -616,9 +616,9 @@ discard block |
||
| 616 | 616 | foreach ( $editable_roles as $role => $details ) { |
| 617 | 617 | $name = translate_user_role( $details['name'] ); |
| 618 | 618 | ?> |
| 619 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
| 619 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
| 620 | 620 | <?php |
| 621 | - unset($role, $details); |
|
| 621 | + unset( $role, $details ); |
|
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | public static function maybe_add_permissions() { |
| 675 | 675 | self::force_capability( 'frm_view_entries' ); |
| 676 | 676 | |
| 677 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 677 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
| 678 | 678 | return; |
| 679 | 679 | } |
| 680 | 680 | |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | $frm_roles = self::frm_capabilities(); |
| 684 | 684 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 685 | 685 | $user->add_cap( $frm_role ); |
| 686 | - unset($frm_role, $frm_role_description); |
|
| 686 | + unset( $frm_role, $frm_role_description ); |
|
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | |
@@ -708,12 +708,12 @@ discard block |
||
| 708 | 708 | * @param string $permission |
| 709 | 709 | */ |
| 710 | 710 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 711 | - $permission_error = self::permission_nonce_error($permission); |
|
| 711 | + $permission_error = self::permission_nonce_error( $permission ); |
|
| 712 | 712 | if ( $permission_error !== false ) { |
| 713 | 713 | if ( 'hide' == $show_message ) { |
| 714 | 714 | $permission_error = ''; |
| 715 | 715 | } |
| 716 | - wp_die($permission_error); |
|
| 716 | + wp_die( $permission_error ); |
|
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
@@ -730,11 +730,11 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | $error = false; |
| 733 | - if ( empty($nonce_name) ) { |
|
| 733 | + if ( empty( $nonce_name ) ) { |
|
| 734 | 734 | return $error; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 737 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
| 738 | 738 | $frm_settings = self::get_settings(); |
| 739 | 739 | $error = $frm_settings->admin_permission; |
| 740 | 740 | } |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | } else { |
| 815 | 815 | foreach ( $value as $k => $v ) { |
| 816 | 816 | if ( ! is_array( $v ) ) { |
| 817 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
| 817 | + $value[$k] = call_user_func( $original_function, $v ); |
|
| 818 | 818 | } |
| 819 | 819 | } |
| 820 | 820 | } |
@@ -835,11 +835,11 @@ discard block |
||
| 835 | 835 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 836 | 836 | $return = array(); |
| 837 | 837 | foreach ( $array as $key => $value ) { |
| 838 | - if ( is_array($value) ) { |
|
| 838 | + if ( is_array( $value ) ) { |
|
| 839 | 839 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 840 | 840 | } else { |
| 841 | 841 | if ( $keys == 'keep' ) { |
| 842 | - $return[ $key ] = $value; |
|
| 842 | + $return[$key] = $value; |
|
| 843 | 843 | } else { |
| 844 | 844 | $return[] = $value; |
| 845 | 845 | } |
@@ -862,8 +862,8 @@ discard block |
||
| 862 | 862 | * @since 2.0 |
| 863 | 863 | */ |
| 864 | 864 | public static function use_wpautop( $content ) { |
| 865 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 866 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 865 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
| 866 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
| 867 | 867 | } |
| 868 | 868 | return $content; |
| 869 | 869 | } |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | */ |
| 883 | 883 | public static function jquery_ui_base_url() { |
| 884 | 884 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 885 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 885 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
| 886 | 886 | return $url; |
| 887 | 887 | } |
| 888 | 888 | |
@@ -896,11 +896,11 @@ discard block |
||
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | $ver = $default; |
| 899 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 899 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
| 900 | 900 | return $ver; |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | - $query = $wp_scripts->registered[ $handle ]; |
|
| 903 | + $query = $wp_scripts->registered[$handle]; |
|
| 904 | 904 | if ( is_object( $query ) && ! empty( $query->ver ) ) { |
| 905 | 905 | $ver = $query->ver; |
| 906 | 906 | } |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | public static function get_user_id_param( $user_id ) { |
| 916 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 916 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
| 917 | 917 | return $user_id; |
| 918 | 918 | } |
| 919 | 919 | |
@@ -921,29 +921,29 @@ discard block |
||
| 921 | 921 | if ( $user_id == 'current' ) { |
| 922 | 922 | $user_id = get_current_user_id(); |
| 923 | 923 | } else { |
| 924 | - if ( is_email($user_id) ) { |
|
| 925 | - $user = get_user_by('email', $user_id); |
|
| 924 | + if ( is_email( $user_id ) ) { |
|
| 925 | + $user = get_user_by( 'email', $user_id ); |
|
| 926 | 926 | } else { |
| 927 | - $user = get_user_by('login', $user_id); |
|
| 927 | + $user = get_user_by( 'login', $user_id ); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | if ( $user ) { |
| 931 | 931 | $user_id = $user->ID; |
| 932 | 932 | } |
| 933 | - unset($user); |
|
| 933 | + unset( $user ); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | return $user_id; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | public static function get_file_contents( $filename, $atts = array() ) { |
| 940 | - if ( ! is_file($filename) ) { |
|
| 940 | + if ( ! is_file( $filename ) ) { |
|
| 941 | 941 | return false; |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | - extract($atts); |
|
| 944 | + extract( $atts ); |
|
| 945 | 945 | ob_start(); |
| 946 | - include($filename); |
|
| 946 | + include( $filename ); |
|
| 947 | 947 | $contents = ob_get_contents(); |
| 948 | 948 | ob_end_clean(); |
| 949 | 949 | return $contents; |
@@ -959,16 +959,16 @@ discard block |
||
| 959 | 959 | $key = ''; |
| 960 | 960 | |
| 961 | 961 | if ( ! empty( $name ) ) { |
| 962 | - $key = sanitize_key($name); |
|
| 962 | + $key = sanitize_key( $name ); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | if ( empty( $key ) ) { |
| 966 | - $max_slug_value = pow(36, $num_chars); |
|
| 966 | + $max_slug_value = pow( 36, $num_chars ); |
|
| 967 | 967 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
| 968 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 968 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 971 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 972 | 972 | $key = $key . 'a'; |
| 973 | 973 | } |
| 974 | 974 | |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | 'ID !' => $id, |
| 978 | 978 | ), $column ); |
| 979 | 979 | |
| 980 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 980 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
| 981 | 981 | $suffix = 2; |
| 982 | 982 | do { |
| 983 | 983 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | $column => $alt_post_name, |
| 986 | 986 | 'ID !' => $id, |
| 987 | 987 | ), $column ); |
| 988 | - $suffix++; |
|
| 988 | + $suffix ++; |
|
| 989 | 989 | } while ( $key_check || is_numeric( $key_check ) ); |
| 990 | 990 | $key = $alt_post_name; |
| 991 | 991 | } |
@@ -1002,8 +1002,8 @@ discard block |
||
| 1002 | 1002 | return false; |
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | - if ( empty($post_values) ) { |
|
| 1006 | - $post_values = stripslashes_deep($_POST); |
|
| 1005 | + if ( empty( $post_values ) ) { |
|
| 1006 | + $post_values = stripslashes_deep( $_POST ); |
|
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | $values = array( |
@@ -1012,25 +1012,25 @@ discard block |
||
| 1012 | 1012 | ); |
| 1013 | 1013 | |
| 1014 | 1014 | foreach ( array( 'name', 'description' ) as $var ) { |
| 1015 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1016 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 1017 | - unset($var, $default_val); |
|
| 1015 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
| 1016 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 1017 | + unset( $var, $default_val ); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 1020 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
| 1021 | 1021 | $frm_settings = self::get_settings(); |
| 1022 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 1022 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
| 1023 | 1023 | |
| 1024 | 1024 | foreach ( (array) $fields as $field ) { |
| 1025 | 1025 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
| 1026 | 1026 | if ( ! $is_form_builder ) { |
| 1027 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 1027 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
| 1028 | 1028 | } |
| 1029 | 1029 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 1030 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
| 1030 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1033 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
| 1034 | 1034 | |
| 1035 | 1035 | if ( $table == 'entries' ) { |
| 1036 | 1036 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1047,8 +1047,8 @@ discard block |
||
| 1047 | 1047 | if ( $args['default'] ) { |
| 1048 | 1048 | $meta_value = $field->default_value; |
| 1049 | 1049 | } else { |
| 1050 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1051 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1050 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
| 1051 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
| 1052 | 1052 | $field->field_options['custom_field'] = ''; |
| 1053 | 1053 | } |
| 1054 | 1054 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( |
@@ -1062,8 +1062,8 @@ discard block |
||
| 1062 | 1062 | } |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
| 1066 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1065 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
| 1066 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
| 1067 | 1067 | |
| 1068 | 1068 | $field_array = array( |
| 1069 | 1069 | 'id' => $field->id, |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | 'default_value' => $field->default_value, |
| 1072 | 1072 | 'name' => $field->name, |
| 1073 | 1073 | 'description' => $field->description, |
| 1074 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1074 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
| 1075 | 1075 | 'options' => $field->options, |
| 1076 | 1076 | 'required' => $field->required, |
| 1077 | 1077 | 'field_key' => $field->field_key, |
@@ -1081,40 +1081,40 @@ discard block |
||
| 1081 | 1081 | ); |
| 1082 | 1082 | |
| 1083 | 1083 | $args['field_type'] = $field_type; |
| 1084 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1084 | + self::fill_field_opts( $field, $field_array, $args ); |
|
| 1085 | 1085 | // Track the original field's type |
| 1086 | 1086 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1087 | 1087 | |
| 1088 | 1088 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
| 1089 | 1089 | |
| 1090 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1090 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
| 1091 | 1091 | $field_array['unique_msg'] = ''; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | $field_array = array_merge( $field->field_options, $field_array ); |
| 1095 | 1095 | |
| 1096 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1096 | + $values['fields'][$field->id] = $field_array; |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1100 | 1100 | $post_values = $args['post_values']; |
| 1101 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1101 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
| 1102 | 1102 | |
| 1103 | 1103 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 1104 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
| 1105 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1106 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1107 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1104 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
| 1105 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
| 1106 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
| 1107 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
| 1108 | 1108 | if ( $args['field_type'] == 'captcha' ) { |
| 1109 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1109 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
| 1110 | 1110 | } else { |
| 1111 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1111 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | } |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | if ( $field_array['custom_html'] == '' ) { |
| 1117 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1117 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | } |
| 1120 | 1120 | |
@@ -1133,18 +1133,18 @@ discard block |
||
| 1133 | 1133 | return; |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1136 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
| 1137 | 1137 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1138 | 1138 | |
| 1139 | - if ( ! is_array($form->options) ) { |
|
| 1139 | + if ( ! is_array( $form->options ) ) { |
|
| 1140 | 1140 | return; |
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | foreach ( $form->options as $opt => $value ) { |
| 1144 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1144 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | - self::fill_form_defaults($post_values, $values); |
|
| 1147 | + self::fill_form_defaults( $post_values, $values ); |
|
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | 1150 | /** |
@@ -1154,11 +1154,11 @@ discard block |
||
| 1154 | 1154 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 1155 | 1155 | |
| 1156 | 1156 | foreach ( $form_defaults as $opt => $default ) { |
| 1157 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1158 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
| 1157 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
| 1158 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | - unset($opt, $defaut); |
|
| 1161 | + unset( $opt, $defaut ); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | 1164 | if ( ! isset( $values['custom_style'] ) ) { |
@@ -1166,10 +1166,10 @@ discard block |
||
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1169 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
| 1170 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1169 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
| 1170 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1171 | 1171 | } |
| 1172 | - unset($h); |
|
| 1172 | + unset( $h ); |
|
| 1173 | 1173 | } |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1200,9 +1200,9 @@ discard block |
||
| 1200 | 1200 | } |
| 1201 | 1201 | ?> |
| 1202 | 1202 | <li> |
| 1203 | - <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
| 1204 | - <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
|
| 1205 | - <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
|
| 1203 | + <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
| 1204 | + <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a> |
|
| 1205 | + <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a> |
|
| 1206 | 1206 | </li> |
| 1207 | 1207 | <?php |
| 1208 | 1208 | } |
@@ -1231,18 +1231,18 @@ discard block |
||
| 1231 | 1231 | foreach ( $words as $word ) { |
| 1232 | 1232 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1233 | 1233 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1234 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1234 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
| 1235 | 1235 | break; |
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | 1238 | $sub .= $part; |
| 1239 | 1239 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1240 | 1240 | |
| 1241 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1241 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
| 1242 | 1242 | break; |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | - unset($total_len, $word); |
|
| 1245 | + unset( $total_len, $word ); |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
@@ -1258,17 +1258,17 @@ discard block |
||
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | 1260 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1261 | - if ( empty($date) ) { |
|
| 1261 | + if ( empty( $date ) ) { |
|
| 1262 | 1262 | return $date; |
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | - if ( empty($date_format) ) { |
|
| 1266 | - $date_format = get_option('date_format'); |
|
| 1265 | + if ( empty( $date_format ) ) { |
|
| 1266 | + $date_format = get_option( 'date_format' ); |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1269 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
| 1270 | 1270 | $frmpro_settings = new FrmProSettings(); |
| 1271 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1271 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | |
| 1284 | 1284 | private static function add_time_to_date( $time_format, $date ) { |
| 1285 | 1285 | if ( empty( $time_format ) ) { |
| 1286 | - $time_format = get_option('time_format'); |
|
| 1286 | + $time_format = get_option( 'time_format' ); |
|
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | 1289 | $trimmed_format = trim( $time_format ); |
@@ -1329,10 +1329,10 @@ discard block |
||
| 1329 | 1329 | $time_strings = self::get_time_strings(); |
| 1330 | 1330 | |
| 1331 | 1331 | foreach ( $time_strings as $k => $v ) { |
| 1332 | - if ( $diff[ $k ] ) { |
|
| 1333 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
| 1332 | + if ( $diff[$k] ) { |
|
| 1333 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
| 1334 | 1334 | } else { |
| 1335 | - unset( $time_strings[ $k ] ); |
|
| 1335 | + unset( $time_strings[$k] ); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | } |
| 1338 | 1338 | |
@@ -1387,19 +1387,19 @@ discard block |
||
| 1387 | 1387 | public static function json_to_array( $json_vars ) { |
| 1388 | 1388 | $vars = array(); |
| 1389 | 1389 | foreach ( $json_vars as $jv ) { |
| 1390 | - $jv_name = explode('[', $jv['name']); |
|
| 1391 | - $last = count($jv_name) - 1; |
|
| 1390 | + $jv_name = explode( '[', $jv['name'] ); |
|
| 1391 | + $last = count( $jv_name ) - 1; |
|
| 1392 | 1392 | foreach ( $jv_name as $p => $n ) { |
| 1393 | - $name = trim($n, ']'); |
|
| 1394 | - if ( ! isset($l1) ) { |
|
| 1393 | + $name = trim( $n, ']' ); |
|
| 1394 | + if ( ! isset( $l1 ) ) { |
|
| 1395 | 1395 | $l1 = $name; |
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | - if ( ! isset($l2) ) { |
|
| 1398 | + if ( ! isset( $l2 ) ) { |
|
| 1399 | 1399 | $l2 = $name; |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | - if ( ! isset($l3) ) { |
|
| 1402 | + if ( ! isset( $l3 ) ) { |
|
| 1403 | 1403 | $l3 = $name; |
| 1404 | 1404 | } |
| 1405 | 1405 | |
@@ -1413,23 +1413,23 @@ discard block |
||
| 1413 | 1413 | |
| 1414 | 1414 | case 1: |
| 1415 | 1415 | $l2 = $name; |
| 1416 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1416 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
| 1417 | 1417 | break; |
| 1418 | 1418 | |
| 1419 | 1419 | case 2: |
| 1420 | 1420 | $l3 = $name; |
| 1421 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1421 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
| 1422 | 1422 | break; |
| 1423 | 1423 | |
| 1424 | 1424 | case 3: |
| 1425 | 1425 | $l4 = $name; |
| 1426 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1426 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | - unset($this_val, $n); |
|
| 1429 | + unset( $this_val, $n ); |
|
| 1430 | 1430 | } |
| 1431 | 1431 | |
| 1432 | - unset($last, $jv); |
|
| 1432 | + unset( $last, $jv ); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | return $vars; |
@@ -1442,8 +1442,8 @@ discard block |
||
| 1442 | 1442 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
| 1443 | 1443 | if ( $name == '' ) { |
| 1444 | 1444 | $vars[] = $val; |
| 1445 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1446 | - $vars[ $l1 ] = $val; |
|
| 1445 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
| 1446 | + $vars[$l1] = $val; |
|
| 1447 | 1447 | } |
| 1448 | 1448 | } |
| 1449 | 1449 | |
@@ -1458,7 +1458,7 @@ discard block |
||
| 1458 | 1458 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
| 1459 | 1459 | ); |
| 1460 | 1460 | |
| 1461 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1461 | + if ( ! isset( $tooltips[$name] ) ) { |
|
| 1462 | 1462 | return; |
| 1463 | 1463 | } |
| 1464 | 1464 | |
@@ -1468,7 +1468,7 @@ discard block |
||
| 1468 | 1468 | echo ' class="frm_help"'; |
| 1469 | 1469 | } |
| 1470 | 1470 | |
| 1471 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
| 1471 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
| 1472 | 1472 | |
| 1473 | 1473 | if ( 'open' != $class ) { |
| 1474 | 1474 | echo '"'; |
@@ -1520,13 +1520,13 @@ discard block |
||
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1523 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
| 1523 | + if ( ! isset( $post_content[$key] ) ) { |
|
| 1524 | 1524 | return; |
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | if ( is_array( $val ) ) { |
| 1528 | 1528 | foreach ( $val as $k1 => $v1 ) { |
| 1529 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
| 1529 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
| 1530 | 1530 | unset( $k1, $v1 ); |
| 1531 | 1531 | } |
| 1532 | 1532 | } else { |
@@ -1534,22 +1534,22 @@ discard block |
||
| 1534 | 1534 | $val = stripslashes( $val ); |
| 1535 | 1535 | |
| 1536 | 1536 | // Add backslashes before double quotes and forward slashes only |
| 1537 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
| 1537 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
| 1538 | 1538 | } |
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | public static function maybe_json_decode( $string ) { |
| 1542 | - if ( is_array($string) ) { |
|
| 1542 | + if ( is_array( $string ) ) { |
|
| 1543 | 1543 | return $string; |
| 1544 | 1544 | } |
| 1545 | 1545 | |
| 1546 | - $new_string = json_decode($string, true); |
|
| 1547 | - if ( function_exists('json_last_error') ) { |
|
| 1546 | + $new_string = json_decode( $string, true ); |
|
| 1547 | + if ( function_exists( 'json_last_error' ) ) { |
|
| 1548 | 1548 | // php 5.3+ |
| 1549 | 1549 | if ( json_last_error() == JSON_ERROR_NONE ) { |
| 1550 | 1550 | $string = $new_string; |
| 1551 | 1551 | } |
| 1552 | - } else if ( isset($new_string) ) { |
|
| 1552 | + } else if ( isset( $new_string ) ) { |
|
| 1553 | 1553 | // php < 5.3 fallback |
| 1554 | 1554 | $string = $new_string; |
| 1555 | 1555 | } |
@@ -1565,11 +1565,11 @@ discard block |
||
| 1565 | 1565 | public static function maybe_highlight_menu( $post_type ) { |
| 1566 | 1566 | global $post; |
| 1567 | 1567 | |
| 1568 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1568 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1569 | 1569 | return; |
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1572 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
| 1573 | 1573 | return; |
| 1574 | 1574 | } |
| 1575 | 1575 | |
@@ -1673,11 +1673,11 @@ discard block |
||
| 1673 | 1673 | $frm_version = self::plugin_version(); |
| 1674 | 1674 | |
| 1675 | 1675 | // check if Formidable meets minimum requirements |
| 1676 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1676 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
| 1677 | 1677 | return; |
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1680 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 1681 | 1681 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1682 | 1682 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
| 1683 | 1683 | '</div></td></tr>'; |
@@ -1758,8 +1758,8 @@ discard block |
||
| 1758 | 1758 | $unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' ); |
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1762 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1761 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
| 1762 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
| 1763 | 1763 | |
| 1764 | 1764 | return $locales; |
| 1765 | 1765 | } |
@@ -7,73 +7,73 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | - |
|
| 17 | - $values = array(); |
|
| 18 | - |
|
| 19 | - foreach ( $defaults as $var => $default ) { |
|
| 20 | - if ( $var == 'field_options' ) { |
|
| 21 | - $values['field_options'] = array(); |
|
| 22 | - foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - $values[ $var ] = $default; |
|
| 28 | - } |
|
| 29 | - unset($var, $default); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | - if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | - $values['field_options']['data_type'] = $setting; |
|
| 35 | - } else { |
|
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | - $values['options'] = serialize( array( |
|
| 42 | - __( 'Option 1', 'formidable' ), |
|
| 43 | - __( 'Option 2', 'formidable' ), |
|
| 44 | - ) ); |
|
| 45 | - } else if ( $type == 'select' ) { |
|
| 10 | + if ( strpos($type, '|') ) { |
|
| 11 | + list($type, $setting) = explode('|', $type); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | + |
|
| 17 | + $values = array(); |
|
| 18 | + |
|
| 19 | + foreach ( $defaults as $var => $default ) { |
|
| 20 | + if ( $var == 'field_options' ) { |
|
| 21 | + $values['field_options'] = array(); |
|
| 22 | + foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | + $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | + unset($opt_var, $opt_default); |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + $values[ $var ] = $default; |
|
| 28 | + } |
|
| 29 | + unset($var, $default); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | + if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | + $values['field_options']['data_type'] = $setting; |
|
| 35 | + } else { |
|
| 36 | + $values['field_options'][ $setting ] = 1; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | + $values['options'] = serialize( array( |
|
| 42 | + __( 'Option 1', 'formidable' ), |
|
| 43 | + __( 'Option 2', 'formidable' ), |
|
| 44 | + ) ); |
|
| 45 | + } else if ( $type == 'select' ) { |
|
| 46 | 46 | $values['options'] = serialize( array( |
| 47 | 47 | '', |
| 48 | 48 | __( 'Option 1', 'formidable' ), |
| 49 | 49 | ) ); |
| 50 | - } else if ( $type == 'textarea' ) { |
|
| 51 | - $values['field_options']['max'] = '5'; |
|
| 52 | - } else if ( $type == 'captcha' ) { |
|
| 53 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 54 | - $values['invalid'] = $frm_settings->re_msg; |
|
| 50 | + } else if ( $type == 'textarea' ) { |
|
| 51 | + $values['field_options']['max'] = '5'; |
|
| 52 | + } else if ( $type == 'captcha' ) { |
|
| 53 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 54 | + $values['invalid'] = $frm_settings->re_msg; |
|
| 55 | 55 | $values['field_options']['label'] = 'none'; |
| 56 | - } else if ( 'url' == $type ) { |
|
| 57 | - $values['name'] = __( 'Website', 'formidable' ); |
|
| 58 | - } |
|
| 56 | + } else if ( 'url' == $type ) { |
|
| 57 | + $values['name'] = __( 'Website', 'formidable' ); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | $fields = FrmField::field_selection(); |
| 61 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 61 | + $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 62 | 62 | |
| 63 | - if ( isset( $fields[ $type ] ) ) { |
|
| 64 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 65 | - } |
|
| 63 | + if ( isset( $fields[ $type ] ) ) { |
|
| 64 | + $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - unset($fields); |
|
| 67 | + unset($fields); |
|
| 68 | 68 | |
| 69 | - return $values; |
|
| 70 | - } |
|
| 69 | + return $values; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | public static function get_html_id( $field, $plus = '' ) { |
| 73 | 73 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 76 | + public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 77 | 77 | $values = array( |
| 78 | 78 | 'id' => $record->id, |
| 79 | 79 | 'form_id' => $record->form_id, |
@@ -89,40 +89,40 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | if ( $doing_ajax ) { |
| 92 | - $values = $values + $defaults; |
|
| 93 | - $values['form_name'] = ''; |
|
| 92 | + $values = $values + $defaults; |
|
| 93 | + $values['form_name'] = ''; |
|
| 94 | 94 | } else { |
| 95 | 95 | foreach ( $defaults as $var => $default ) { |
| 96 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 97 | - unset($var, $default); |
|
| 98 | - } |
|
| 96 | + $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 97 | + unset($var, $default); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
| 101 | - } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | 103 | unset( $defaults ); |
| 104 | 104 | |
| 105 | - $values['options'] = $record->options; |
|
| 106 | - $values['field_options'] = $record->field_options; |
|
| 105 | + $values['options'] = $record->options; |
|
| 106 | + $values['field_options'] = $record->field_options; |
|
| 107 | 107 | |
| 108 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 108 | + $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 109 | 109 | |
| 110 | 110 | if ( $values['type'] == 'captcha' ) { |
| 111 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 112 | - $defaults['invalid'] = $frm_settings->re_msg; |
|
| 113 | - } |
|
| 111 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 112 | + $defaults['invalid'] = $frm_settings->re_msg; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | foreach ( $defaults as $opt => $default ) { |
| 116 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 117 | - unset($opt, $default); |
|
| 118 | - } |
|
| 116 | + $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 117 | + unset($opt, $default); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type ); |
| 121 | 121 | |
| 122 | 122 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 123 | - } |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 125 | + public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 126 | 126 | $field_options = array( |
| 127 | 127 | 'size' => '', |
| 128 | 128 | 'max' => '', |
@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | 142 | if ( $limit ) { |
| 143 | - return $field_options; |
|
| 143 | + return $field_options; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - global $wpdb; |
|
| 146 | + global $wpdb; |
|
| 147 | 147 | |
| 148 | 148 | $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id; |
| 149 | 149 | |
| 150 | 150 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 151 | 151 | |
| 152 | - $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 152 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 153 | 153 | |
| 154 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 154 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 155 | 155 | return array( |
| 156 | 156 | 'name' => __( 'Untitled', 'formidable' ), |
| 157 | 157 | 'description' => '', |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | 'form_id' => $form_id, |
| 168 | 168 | 'field_options' => $field_options, |
| 169 | 169 | ); |
| 170 | - } |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 173 | - global $wpdb; |
|
| 172 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 173 | + global $wpdb; |
|
| 174 | 174 | |
| 175 | 175 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 176 | - $values['form_id'] = $form_id; |
|
| 177 | - $values['options'] = maybe_serialize($field->options); |
|
| 178 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 179 | - |
|
| 180 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 181 | - $values[ $col ] = $field->{$col}; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * @since 2.0 |
|
| 187 | - */ |
|
| 176 | + $values['form_id'] = $form_id; |
|
| 177 | + $values['options'] = maybe_serialize($field->options); |
|
| 178 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
| 179 | + |
|
| 180 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 181 | + $values[ $col ] = $field->{$col}; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @since 2.0 |
|
| 187 | + */ |
|
| 188 | 188 | public static function get_error_msg( $field, $error ) { |
| 189 | 189 | $frm_settings = FrmAppHelper::get_settings(); |
| 190 | 190 | $default_settings = $frm_settings->default_options(); |
@@ -225,12 +225,12 @@ discard block |
||
| 225 | 225 | public static function get_default_html( $type = 'text' ) { |
| 226 | 226 | if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) { |
| 227 | 227 | $input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]'; |
| 228 | - $for = ''; |
|
| 228 | + $for = ''; |
|
| 229 | 229 | if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) { |
| 230 | - $for = 'for="field_[key]"'; |
|
| 231 | - } |
|
| 230 | + $for = 'for="field_[key]"'; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - $default_html = <<<DEFAULT_HTML |
|
| 233 | + $default_html = <<<DEFAULT_HTML |
|
| 234 | 234 | <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]"> |
| 235 | 235 | <label $for class="frm_primary_label">[field_name] |
| 236 | 236 | <span class="frm_required">[required_label]</span> |
@@ -240,60 +240,60 @@ discard block |
||
| 240 | 240 | [if error]<div class="frm_error">[error]</div>[/if error] |
| 241 | 241 | </div> |
| 242 | 242 | DEFAULT_HTML; |
| 243 | - } else { |
|
| 243 | + } else { |
|
| 244 | 244 | $default_html = apply_filters('frm_other_custom_html', '', $type); |
| 245 | - } |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 248 | - } |
|
| 247 | + return apply_filters('frm_custom_html', $default_html, $type); |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 251 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 251 | + $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 252 | 252 | |
| 253 | - $defaults = array( |
|
| 253 | + $defaults = array( |
|
| 254 | 254 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
| 255 | 255 | 'field_id' => $field['id'], |
| 256 | - 'field_plus_id' => '', |
|
| 257 | - 'section_id' => '', |
|
| 258 | - ); |
|
| 259 | - $args = wp_parse_args($args, $defaults); |
|
| 260 | - $field_name = $args['field_name']; |
|
| 261 | - $field_id = $args['field_id']; |
|
| 262 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 256 | + 'field_plus_id' => '', |
|
| 257 | + 'section_id' => '', |
|
| 258 | + ); |
|
| 259 | + $args = wp_parse_args($args, $defaults); |
|
| 260 | + $field_name = $args['field_name']; |
|
| 261 | + $field_id = $args['field_id']; |
|
| 262 | + $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 263 | 263 | |
| 264 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 265 | - $field_name .= '[]'; |
|
| 266 | - } |
|
| 264 | + if ( FrmField::is_multiple_select($field) ) { |
|
| 265 | + $field_name .= '[]'; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - //replace [id] |
|
| 269 | - $html = str_replace('[id]', $field_id, $html); |
|
| 268 | + //replace [id] |
|
| 269 | + $html = str_replace('[id]', $field_id, $html); |
|
| 270 | 270 | |
| 271 | - // Remove the for attribute for captcha |
|
| 272 | - if ( $field['type'] == 'captcha' ) { |
|
| 273 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 274 | - } |
|
| 271 | + // Remove the for attribute for captcha |
|
| 272 | + if ( $field['type'] == 'captcha' ) { |
|
| 273 | + $html = str_replace(' for="field_[key]"', '', $html); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - // set the label for |
|
| 277 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 276 | + // set the label for |
|
| 277 | + $html = str_replace('field_[key]', $html_id, $html); |
|
| 278 | 278 | |
| 279 | - //replace [key] |
|
| 280 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 279 | + //replace [key] |
|
| 280 | + $html = str_replace('[key]', $field['field_key'], $html); |
|
| 281 | 281 | |
| 282 | - //replace [description] and [required_label] and [error] |
|
| 282 | + //replace [description] and [required_label] and [error] |
|
| 283 | 283 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 284 | - if ( ! is_array( $errors ) ) { |
|
| 285 | - $errors = array(); |
|
| 286 | - } |
|
| 284 | + if ( ! is_array( $errors ) ) { |
|
| 285 | + $errors = array(); |
|
| 286 | + } |
|
| 287 | 287 | $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
| 288 | 288 | |
| 289 | - //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 290 | - if ( $field['type'] == 'divider' ) { |
|
| 291 | - if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 292 | - $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 293 | - } else { |
|
| 294 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 295 | - } |
|
| 296 | - } |
|
| 289 | + //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 290 | + if ( $field['type'] == 'divider' ) { |
|
| 291 | + if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 292 | + $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 293 | + } else { |
|
| 294 | + $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | 298 | $codes = array( |
| 299 | 299 | 'description' => $field['description'], |
@@ -301,25 +301,25 @@ discard block |
||
| 301 | 301 | 'error' => $error, |
| 302 | 302 | ); |
| 303 | 303 | foreach ( $codes as $code => $value ) { |
| 304 | - self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 305 | - } |
|
| 304 | + self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - //replace [required_class] |
|
| 307 | + //replace [required_class] |
|
| 308 | 308 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 309 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 309 | + $html = str_replace('[required_class]', $required_class, $html); |
|
| 310 | 310 | |
| 311 | - //replace [label_position] |
|
| 311 | + //replace [label_position] |
|
| 312 | 312 | $field['label'] = self::label_position( $field['label'], $field, $form ); |
| 313 | 313 | self::add_class_to_label( $field, $html ); |
| 314 | 314 | |
| 315 | - //replace [field_name] |
|
| 316 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 315 | + //replace [field_name] |
|
| 316 | + $html = str_replace('[field_name]', $field['name'], $html); |
|
| 317 | 317 | |
| 318 | 318 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
| 319 | 319 | |
| 320 | - //replace [entry_key] |
|
| 321 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 322 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 320 | + //replace [entry_key] |
|
| 321 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 322 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 323 | 323 | |
| 324 | 324 | if ( $form ) { |
| 325 | 325 | $form = (array) $form; |
@@ -333,51 +333,51 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | self::process_wp_shortcodes( $html ); |
| 335 | 335 | |
| 336 | - //replace [input] |
|
| 337 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 338 | - global $frm_vars; |
|
| 339 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 336 | + //replace [input] |
|
| 337 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 338 | + global $frm_vars; |
|
| 339 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 340 | 340 | |
| 341 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 342 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 341 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 342 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 343 | 343 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( |
| 344 | 344 | 'conditional' => false, |
| 345 | 345 | 'conditional_check' => false, |
| 346 | 346 | ) ); |
| 347 | 347 | |
| 348 | - $replace_with = ''; |
|
| 348 | + $replace_with = ''; |
|
| 349 | 349 | |
| 350 | - if ( $tag == 'input' ) { |
|
| 351 | - if ( isset($atts['opt']) ) { |
|
| 352 | - $atts['opt']--; |
|
| 353 | - } |
|
| 350 | + if ( $tag == 'input' ) { |
|
| 351 | + if ( isset($atts['opt']) ) { |
|
| 352 | + $atts['opt']--; |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 356 | - if ( isset($atts['class']) ) { |
|
| 357 | - unset($atts['class']); |
|
| 358 | - } |
|
| 355 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 356 | + if ( isset($atts['class']) ) { |
|
| 357 | + unset($atts['class']); |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - $field['shortcodes'] = $atts; |
|
| 361 | - ob_start(); |
|
| 360 | + $field['shortcodes'] = $atts; |
|
| 361 | + ob_start(); |
|
| 362 | 362 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
| 363 | - $replace_with = ob_get_contents(); |
|
| 364 | - ob_end_clean(); |
|
| 365 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 366 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 367 | - } |
|
| 363 | + $replace_with = ob_get_contents(); |
|
| 364 | + ob_end_clean(); |
|
| 365 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 366 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 370 | - } |
|
| 369 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - $html .= "\n"; |
|
| 372 | + $html .= "\n"; |
|
| 373 | 373 | |
| 374 | - //Return html if conf_field to prevent loop |
|
| 375 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 376 | - return $html; |
|
| 377 | - } |
|
| 374 | + //Return html if conf_field to prevent loop |
|
| 375 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 376 | + return $html; |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - //If field is in repeating section |
|
| 380 | - if ( $args['section_id'] ) { |
|
| 379 | + //If field is in repeating section |
|
| 380 | + if ( $args['section_id'] ) { |
|
| 381 | 381 | $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( |
| 382 | 382 | 'errors' => $errors, |
| 383 | 383 | 'form' => $form, |
@@ -386,17 +386,17 @@ discard block |
||
| 386 | 386 | 'field_plus_id' => $args['field_plus_id'], |
| 387 | 387 | 'section_id' => $args['section_id'], |
| 388 | 388 | ) ); |
| 389 | - } else { |
|
| 389 | + } else { |
|
| 390 | 390 | $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( |
| 391 | 391 | 'errors' => $errors, |
| 392 | 392 | 'form' => $form, |
| 393 | 393 | ) ); |
| 394 | - } |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | 396 | self::remove_collapse_shortcode( $html ); |
| 397 | 397 | |
| 398 | - return $html; |
|
| 399 | - } |
|
| 398 | + return $html; |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | 401 | /** |
| 402 | 402 | * Get the class to use for the label position |
@@ -507,16 +507,16 @@ discard block |
||
| 507 | 507 | return $classes; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 511 | - if ( $no_vars ) { |
|
| 510 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 511 | + if ( $no_vars ) { |
|
| 512 | 512 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 513 | 513 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
| 514 | - } else { |
|
| 514 | + } else { |
|
| 515 | 515 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
| 516 | - } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | 518 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
| 519 | - } |
|
| 519 | + } |
|
| 520 | 520 | |
| 521 | 521 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 522 | 522 | $args = wp_parse_args( $args, array( |
@@ -524,33 +524,33 @@ discard block |
||
| 524 | 524 | 'conditional_check' => false, |
| 525 | 525 | 'foreach' => false, |
| 526 | 526 | ) ); |
| 527 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 528 | - $args['conditional_check'] = true; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - $prefix = ''; |
|
| 532 | - if ( $args['conditional_check'] ) { |
|
| 533 | - if ( $args['conditional'] ) { |
|
| 534 | - $prefix = 'if '; |
|
| 535 | - } else if ( $args['foreach'] ) { |
|
| 536 | - $prefix = 'foreach '; |
|
| 537 | - } |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 541 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 542 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 543 | - $tag = str_replace(']', '', $tag); |
|
| 544 | - $tags = explode(' ', $tag); |
|
| 545 | - if ( is_array($tags) ) { |
|
| 546 | - $tag = $tags[0]; |
|
| 547 | - } |
|
| 548 | - } else { |
|
| 549 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - return $tag; |
|
| 553 | - } |
|
| 527 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 528 | + $args['conditional_check'] = true; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + $prefix = ''; |
|
| 532 | + if ( $args['conditional_check'] ) { |
|
| 533 | + if ( $args['conditional'] ) { |
|
| 534 | + $prefix = 'if '; |
|
| 535 | + } else if ( $args['foreach'] ) { |
|
| 536 | + $prefix = 'foreach '; |
|
| 537 | + } |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 541 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 542 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 543 | + $tag = str_replace(']', '', $tag); |
|
| 544 | + $tags = explode(' ', $tag); |
|
| 545 | + if ( is_array($tags) ) { |
|
| 546 | + $tag = $tags[0]; |
|
| 547 | + } |
|
| 548 | + } else { |
|
| 549 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + return $tag; |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | 555 | /** |
| 556 | 556 | * Remove [collapse_this] if it's still included after all processing |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | } |
| 589 | 589 | $api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url ); |
| 590 | 590 | |
| 591 | - wp_register_script( 'recaptcha-api', $api_js_url, array( 'formidable' ), true ); |
|
| 592 | - wp_enqueue_script( 'recaptcha-api' ); |
|
| 591 | + wp_register_script( 'recaptcha-api', $api_js_url, array( 'formidable' ), true ); |
|
| 592 | + wp_enqueue_script( 'recaptcha-api' ); |
|
| 593 | 593 | |
| 594 | 594 | // for reverse compatibility |
| 595 | 595 | $field['captcha_size'] = ( $field['captcha_size'] == 'default' ) ? 'normal' : $field['captcha_size']; |
@@ -598,68 +598,68 @@ discard block |
||
| 598 | 598 | ?> |
| 599 | 599 | <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>" <?php if ( 'invisible' === $field['captcha_size'] && ! $allow_mutiple ) { echo 'data-callback="frmAfterRecaptcha"'; } ?>></div> |
| 600 | 600 | <?php |
| 601 | - } |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | 603 | public static function show_single_option( $field ) { |
| 604 | - $field_name = $field['name']; |
|
| 605 | - $html_id = self::get_html_id($field); |
|
| 606 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 607 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 608 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 604 | + $field_name = $field['name']; |
|
| 605 | + $html_id = self::get_html_id($field); |
|
| 606 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 607 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 608 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 609 | 609 | |
| 610 | - // If this is an "Other" option, get the HTML for it |
|
| 610 | + // If this is an "Other" option, get the HTML for it |
|
| 611 | 611 | if ( self::is_other_opt( $opt_key ) ) { |
| 612 | - // Get string for Other text field, if needed |
|
| 612 | + // Get string for Other text field, if needed |
|
| 613 | 613 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 614 | 614 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 615 | - } else { |
|
| 615 | + } else { |
|
| 616 | 616 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 617 | - } |
|
| 618 | - } |
|
| 619 | - } |
|
| 617 | + } |
|
| 618 | + } |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | public static function get_term_link( $tax_id ) { |
| 622 | - $tax = get_taxonomy($tax_id); |
|
| 623 | - if ( ! $tax ) { |
|
| 624 | - return; |
|
| 625 | - } |
|
| 622 | + $tax = get_taxonomy($tax_id); |
|
| 623 | + if ( ! $tax ) { |
|
| 624 | + return; |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | - $link = sprintf( |
|
| 628 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 627 | + $link = sprintf( |
|
| 628 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 629 | 629 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 630 | - ); |
|
| 631 | - unset($tax); |
|
| 630 | + ); |
|
| 631 | + unset($tax); |
|
| 632 | 632 | |
| 633 | - return $link; |
|
| 634 | - } |
|
| 633 | + return $link; |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | 636 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 637 | 637 | $hide_opt = self::get_value_for_comparision( $hide_opt ); |
| 638 | 638 | $observed_value = self::get_value_for_comparision( $observed_value ); |
| 639 | 639 | |
| 640 | - if ( is_array($observed_value) ) { |
|
| 641 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - $m = false; |
|
| 645 | - if ( $cond == '==' ) { |
|
| 646 | - $m = $observed_value == $hide_opt; |
|
| 647 | - } else if ( $cond == '!=' ) { |
|
| 648 | - $m = $observed_value != $hide_opt; |
|
| 649 | - } else if ( $cond == '>' ) { |
|
| 650 | - $m = $observed_value > $hide_opt; |
|
| 651 | - } else if ( $cond == '<' ) { |
|
| 652 | - $m = $observed_value < $hide_opt; |
|
| 653 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 654 | - $m = stripos($observed_value, $hide_opt); |
|
| 655 | - if ( $cond == 'not LIKE' ) { |
|
| 656 | - $m = ( $m === false ) ? true : false; |
|
| 657 | - } else { |
|
| 658 | - $m = ( $m === false ) ? false : true; |
|
| 659 | - } |
|
| 660 | - } |
|
| 661 | - return $m; |
|
| 662 | - } |
|
| 640 | + if ( is_array($observed_value) ) { |
|
| 641 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + $m = false; |
|
| 645 | + if ( $cond == '==' ) { |
|
| 646 | + $m = $observed_value == $hide_opt; |
|
| 647 | + } else if ( $cond == '!=' ) { |
|
| 648 | + $m = $observed_value != $hide_opt; |
|
| 649 | + } else if ( $cond == '>' ) { |
|
| 650 | + $m = $observed_value > $hide_opt; |
|
| 651 | + } else if ( $cond == '<' ) { |
|
| 652 | + $m = $observed_value < $hide_opt; |
|
| 653 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 654 | + $m = stripos($observed_value, $hide_opt); |
|
| 655 | + if ( $cond == 'not LIKE' ) { |
|
| 656 | + $m = ( $m === false ) ? true : false; |
|
| 657 | + } else { |
|
| 658 | + $m = ( $m === false ) ? false : true; |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + return $m; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | 664 | /** |
| 665 | 665 | * Trim and sanitize the values |
@@ -675,84 +675,84 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 678 | - $m = false; |
|
| 679 | - if ( $cond == '==' ) { |
|
| 680 | - if ( is_array($hide_opt) ) { |
|
| 681 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 682 | - $m = empty($m) ? false : true; |
|
| 683 | - } else { |
|
| 684 | - $m = in_array($hide_opt, $observed_value); |
|
| 685 | - } |
|
| 686 | - } else if ( $cond == '!=' ) { |
|
| 687 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 688 | - } else if ( $cond == '>' ) { |
|
| 689 | - $min = min($observed_value); |
|
| 690 | - $m = $min > $hide_opt; |
|
| 691 | - } else if ( $cond == '<' ) { |
|
| 692 | - $max = max($observed_value); |
|
| 693 | - $m = $max < $hide_opt; |
|
| 694 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 695 | - foreach ( $observed_value as $ob ) { |
|
| 696 | - $m = strpos($ob, $hide_opt); |
|
| 697 | - if ( $m !== false ) { |
|
| 698 | - $m = true; |
|
| 699 | - break; |
|
| 700 | - } |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - if ( $cond == 'not LIKE' ) { |
|
| 704 | - $m = ( $m === false ) ? true : false; |
|
| 705 | - } |
|
| 706 | - } |
|
| 707 | - |
|
| 708 | - return $m; |
|
| 709 | - } |
|
| 710 | - |
|
| 711 | - /** |
|
| 712 | - * Replace a few basic shortcodes and field ids |
|
| 713 | - * @since 2.0 |
|
| 714 | - * @return string |
|
| 715 | - */ |
|
| 678 | + $m = false; |
|
| 679 | + if ( $cond == '==' ) { |
|
| 680 | + if ( is_array($hide_opt) ) { |
|
| 681 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 682 | + $m = empty($m) ? false : true; |
|
| 683 | + } else { |
|
| 684 | + $m = in_array($hide_opt, $observed_value); |
|
| 685 | + } |
|
| 686 | + } else if ( $cond == '!=' ) { |
|
| 687 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 688 | + } else if ( $cond == '>' ) { |
|
| 689 | + $min = min($observed_value); |
|
| 690 | + $m = $min > $hide_opt; |
|
| 691 | + } else if ( $cond == '<' ) { |
|
| 692 | + $max = max($observed_value); |
|
| 693 | + $m = $max < $hide_opt; |
|
| 694 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 695 | + foreach ( $observed_value as $ob ) { |
|
| 696 | + $m = strpos($ob, $hide_opt); |
|
| 697 | + if ( $m !== false ) { |
|
| 698 | + $m = true; |
|
| 699 | + break; |
|
| 700 | + } |
|
| 701 | + } |
|
| 702 | + |
|
| 703 | + if ( $cond == 'not LIKE' ) { |
|
| 704 | + $m = ( $m === false ) ? true : false; |
|
| 705 | + } |
|
| 706 | + } |
|
| 707 | + |
|
| 708 | + return $m; |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + /** |
|
| 712 | + * Replace a few basic shortcodes and field ids |
|
| 713 | + * @since 2.0 |
|
| 714 | + * @return string |
|
| 715 | + */ |
|
| 716 | 716 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 717 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 718 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 719 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 720 | - } |
|
| 717 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 718 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 719 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 720 | + } |
|
| 721 | 721 | |
| 722 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 723 | - $value = do_shortcode($value); |
|
| 722 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 723 | + $value = do_shortcode($value); |
|
| 724 | 724 | |
| 725 | - return $value; |
|
| 726 | - } |
|
| 725 | + return $value; |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | 728 | public static function get_shortcodes( $content, $form_id ) { |
| 729 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 730 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 731 | - } |
|
| 729 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 730 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | 733 | $fields = FrmField::getAll( array( |
| 734 | 734 | 'fi.form_id' => (int) $form_id, |
| 735 | 735 | 'fi.type not' => FrmField::no_save_fields(), |
| 736 | 736 | ) ); |
| 737 | 737 | |
| 738 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 738 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 739 | 739 | |
| 740 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 740 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 741 | 741 | |
| 742 | - return $matches; |
|
| 743 | - } |
|
| 742 | + return $matches; |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | 745 | public static function allowed_shortcodes( $fields = array() ) { |
| 746 | 746 | $tagregexp = array( 'editlink', 'id', 'key', 'ip', 'siteurl', 'sitename', 'admin_email', 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', 'parent[-|_]id' ); |
| 747 | 747 | |
| 748 | - foreach ( $fields as $field ) { |
|
| 749 | - $tagregexp[] = $field->id; |
|
| 750 | - $tagregexp[] = $field->field_key; |
|
| 751 | - } |
|
| 748 | + foreach ( $fields as $field ) { |
|
| 749 | + $tagregexp[] = $field->id; |
|
| 750 | + $tagregexp[] = $field->field_key; |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | - $tagregexp = implode('|', $tagregexp); |
|
| 754 | - return $tagregexp; |
|
| 755 | - } |
|
| 753 | + $tagregexp = implode('|', $tagregexp); |
|
| 754 | + return $tagregexp; |
|
| 755 | + } |
|
| 756 | 756 | |
| 757 | 757 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 758 | 758 | $shortcode_values = array( |
@@ -761,86 +761,86 @@ discard block |
||
| 761 | 761 | 'ip' => $entry->ip, |
| 762 | 762 | ); |
| 763 | 763 | |
| 764 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 764 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 765 | 765 | if ( empty( $tag ) ) { |
| 766 | 766 | continue; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 769 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 770 | 770 | |
| 771 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 771 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 772 | 772 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
| 773 | - $tags = explode(' ', $tag); |
|
| 774 | - if ( is_array($tags) ) { |
|
| 775 | - $tag = $tags[0]; |
|
| 776 | - } |
|
| 777 | - } else { |
|
| 778 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 779 | - } |
|
| 780 | - |
|
| 781 | - switch ( $tag ) { |
|
| 782 | - case 'id': |
|
| 783 | - case 'key': |
|
| 784 | - case 'ip': |
|
| 785 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 773 | + $tags = explode(' ', $tag); |
|
| 774 | + if ( is_array($tags) ) { |
|
| 775 | + $tag = $tags[0]; |
|
| 776 | + } |
|
| 777 | + } else { |
|
| 778 | + $tag = $shortcodes[2][ $short_key ]; |
|
| 779 | + } |
|
| 780 | + |
|
| 781 | + switch ( $tag ) { |
|
| 782 | + case 'id': |
|
| 783 | + case 'key': |
|
| 784 | + case 'ip': |
|
| 785 | + $replace_with = $shortcode_values[ $tag ]; |
|
| 786 | 786 | break; |
| 787 | 787 | |
| 788 | - case 'user_agent': |
|
| 789 | - case 'user-agent': |
|
| 790 | - $entry->description = maybe_unserialize($entry->description); |
|
| 788 | + case 'user_agent': |
|
| 789 | + case 'user-agent': |
|
| 790 | + $entry->description = maybe_unserialize($entry->description); |
|
| 791 | 791 | $replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] ); |
| 792 | 792 | break; |
| 793 | 793 | |
| 794 | - case 'created_at': |
|
| 795 | - case 'created-at': |
|
| 796 | - case 'updated_at': |
|
| 797 | - case 'updated-at': |
|
| 798 | - if ( isset($atts['format']) ) { |
|
| 799 | - $time_format = ' '; |
|
| 800 | - } else { |
|
| 801 | - $atts['format'] = get_option('date_format'); |
|
| 802 | - $time_format = ''; |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - $this_tag = str_replace('-', '_', $tag); |
|
| 806 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 807 | - unset($this_tag); |
|
| 794 | + case 'created_at': |
|
| 795 | + case 'created-at': |
|
| 796 | + case 'updated_at': |
|
| 797 | + case 'updated-at': |
|
| 798 | + if ( isset($atts['format']) ) { |
|
| 799 | + $time_format = ' '; |
|
| 800 | + } else { |
|
| 801 | + $atts['format'] = get_option('date_format'); |
|
| 802 | + $time_format = ''; |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + $this_tag = str_replace('-', '_', $tag); |
|
| 806 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 807 | + unset($this_tag); |
|
| 808 | 808 | break; |
| 809 | 809 | |
| 810 | - case 'created_by': |
|
| 811 | - case 'created-by': |
|
| 812 | - case 'updated_by': |
|
| 813 | - case 'updated-by': |
|
| 814 | - $this_tag = str_replace('-', '_', $tag); |
|
| 810 | + case 'created_by': |
|
| 811 | + case 'created-by': |
|
| 812 | + case 'updated_by': |
|
| 813 | + case 'updated-by': |
|
| 814 | + $this_tag = str_replace('-', '_', $tag); |
|
| 815 | 815 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 816 | - unset($this_tag); |
|
| 816 | + unset($this_tag); |
|
| 817 | 817 | break; |
| 818 | 818 | |
| 819 | - case 'admin_email': |
|
| 820 | - case 'siteurl': |
|
| 821 | - case 'frmurl': |
|
| 822 | - case 'sitename': |
|
| 823 | - case 'get': |
|
| 824 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 819 | + case 'admin_email': |
|
| 820 | + case 'siteurl': |
|
| 821 | + case 'frmurl': |
|
| 822 | + case 'sitename': |
|
| 823 | + case 'get': |
|
| 824 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 825 | 825 | break; |
| 826 | 826 | |
| 827 | - default: |
|
| 828 | - $field = FrmField::getOne( $tag ); |
|
| 829 | - if ( ! $field ) { |
|
| 830 | - break; |
|
| 831 | - } |
|
| 827 | + default: |
|
| 828 | + $field = FrmField::getOne( $tag ); |
|
| 829 | + if ( ! $field ) { |
|
| 830 | + break; |
|
| 831 | + } |
|
| 832 | 832 | |
| 833 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 833 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 834 | 834 | |
| 835 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 835 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 836 | 836 | |
| 837 | - $atts['entry_id'] = $entry->id; |
|
| 838 | - $atts['entry_key'] = $entry->item_key; |
|
| 837 | + $atts['entry_id'] = $entry->id; |
|
| 838 | + $atts['entry_key'] = $entry->item_key; |
|
| 839 | 839 | |
| 840 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 841 | - $replace_with = $field->name; |
|
| 842 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 843 | - $replace_with = $field->description; |
|
| 840 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 841 | + $replace_with = $field->name; |
|
| 842 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 843 | + $replace_with = $field->description; |
|
| 844 | 844 | } else { |
| 845 | 845 | $string_value = $replace_with; |
| 846 | 846 | if ( is_array( $replace_with ) ) { |
@@ -854,81 +854,81 @@ discard block |
||
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | - unset($field); |
|
| 858 | - } |
|
| 857 | + unset($field); |
|
| 858 | + } |
|
| 859 | 859 | |
| 860 | - if ( isset($replace_with) ) { |
|
| 861 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 862 | - } |
|
| 860 | + if ( isset($replace_with) ) { |
|
| 861 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 862 | + } |
|
| 863 | 863 | |
| 864 | - unset($atts, $conditional, $replace_with); |
|
| 864 | + unset($atts, $conditional, $replace_with); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | return $content; |
| 868 | - } |
|
| 869 | - |
|
| 870 | - /** |
|
| 871 | - * Get the value to replace a few standard shortcodes |
|
| 872 | - * |
|
| 873 | - * @since 2.0 |
|
| 874 | - * @return string |
|
| 875 | - */ |
|
| 876 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 877 | - $new_value = ''; |
|
| 878 | - switch ( $tag ) { |
|
| 879 | - case 'admin_email': |
|
| 880 | - $new_value = get_option('admin_email'); |
|
| 881 | - break; |
|
| 882 | - case 'siteurl': |
|
| 883 | - $new_value = FrmAppHelper::site_url(); |
|
| 884 | - break; |
|
| 885 | - case 'frmurl': |
|
| 886 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 887 | - break; |
|
| 888 | - case 'sitename': |
|
| 889 | - $new_value = FrmAppHelper::site_name(); |
|
| 890 | - break; |
|
| 891 | - case 'get': |
|
| 892 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 893 | - break; |
|
| 894 | - } |
|
| 895 | - |
|
| 896 | - return $new_value; |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - /** |
|
| 900 | - * Process the [get] shortcode |
|
| 901 | - * |
|
| 902 | - * @since 2.0 |
|
| 903 | - * @return string|array |
|
| 904 | - */ |
|
| 905 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 906 | - if ( ! isset($atts['param']) ) { |
|
| 907 | - return ''; |
|
| 908 | - } |
|
| 909 | - |
|
| 910 | - if ( strpos($atts['param'], '[') ) { |
|
| 911 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 912 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 913 | - } |
|
| 868 | + } |
|
| 869 | + |
|
| 870 | + /** |
|
| 871 | + * Get the value to replace a few standard shortcodes |
|
| 872 | + * |
|
| 873 | + * @since 2.0 |
|
| 874 | + * @return string |
|
| 875 | + */ |
|
| 876 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 877 | + $new_value = ''; |
|
| 878 | + switch ( $tag ) { |
|
| 879 | + case 'admin_email': |
|
| 880 | + $new_value = get_option('admin_email'); |
|
| 881 | + break; |
|
| 882 | + case 'siteurl': |
|
| 883 | + $new_value = FrmAppHelper::site_url(); |
|
| 884 | + break; |
|
| 885 | + case 'frmurl': |
|
| 886 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 887 | + break; |
|
| 888 | + case 'sitename': |
|
| 889 | + $new_value = FrmAppHelper::site_name(); |
|
| 890 | + break; |
|
| 891 | + case 'get': |
|
| 892 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 893 | + break; |
|
| 894 | + } |
|
| 895 | + |
|
| 896 | + return $new_value; |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + /** |
|
| 900 | + * Process the [get] shortcode |
|
| 901 | + * |
|
| 902 | + * @since 2.0 |
|
| 903 | + * @return string|array |
|
| 904 | + */ |
|
| 905 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 906 | + if ( ! isset($atts['param']) ) { |
|
| 907 | + return ''; |
|
| 908 | + } |
|
| 909 | + |
|
| 910 | + if ( strpos($atts['param'], '[') ) { |
|
| 911 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 912 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | 915 | $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' ); |
| 916 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 916 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 917 | 917 | |
| 918 | - if ( $new_value == '' ) { |
|
| 919 | - if ( ! isset($atts['prev_val']) ) { |
|
| 920 | - $atts['prev_val'] = ''; |
|
| 921 | - } |
|
| 918 | + if ( $new_value == '' ) { |
|
| 919 | + if ( ! isset($atts['prev_val']) ) { |
|
| 920 | + $atts['prev_val'] = ''; |
|
| 921 | + } |
|
| 922 | 922 | |
| 923 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 924 | - } |
|
| 923 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 927 | - $new_value = implode(', ', $new_value); |
|
| 928 | - } |
|
| 926 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 927 | + $new_value = implode(', ', $new_value); |
|
| 928 | + } |
|
| 929 | 929 | |
| 930 | - return $new_value; |
|
| 931 | - } |
|
| 930 | + return $new_value; |
|
| 931 | + } |
|
| 932 | 932 | |
| 933 | 933 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
| 934 | 934 | $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -936,14 +936,14 @@ discard block |
||
| 936 | 936 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
| 937 | 937 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 938 | 938 | |
| 939 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 940 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 941 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 942 | - if ( is_array($replace_with) ) { |
|
| 943 | - $replace_with = implode("\n", $replace_with); |
|
| 944 | - } |
|
| 945 | - $replace_with = wpautop($replace_with); |
|
| 946 | - } |
|
| 939 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 940 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 941 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 942 | + if ( is_array($replace_with) ) { |
|
| 943 | + $replace_with = implode("\n", $replace_with); |
|
| 944 | + } |
|
| 945 | + $replace_with = wpautop($replace_with); |
|
| 946 | + } |
|
| 947 | 947 | unset( $autop ); |
| 948 | 948 | } else if ( is_array( $replace_with ) ) { |
| 949 | 949 | if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[ $atts['show'] ] ) ) { |
@@ -963,27 +963,27 @@ discard block |
||
| 963 | 963 | |
| 964 | 964 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 965 | 965 | |
| 966 | - $field_types = array(); |
|
| 967 | - if ( in_array($type, $single_input) ) { |
|
| 968 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 969 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 970 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 971 | - } else if ( in_array($type, $other_type) ) { |
|
| 972 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 966 | + $field_types = array(); |
|
| 967 | + if ( in_array($type, $single_input) ) { |
|
| 968 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 969 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 970 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 971 | + } else if ( in_array($type, $other_type) ) { |
|
| 972 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 973 | 973 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 974 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 975 | - } |
|
| 974 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 975 | + } |
|
| 976 | 976 | |
| 977 | 977 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 978 | - return $field_types; |
|
| 979 | - } |
|
| 978 | + return $field_types; |
|
| 979 | + } |
|
| 980 | 980 | |
| 981 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 982 | - foreach ( $inputs as $input ) { |
|
| 983 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 984 | - unset($input); |
|
| 985 | - } |
|
| 986 | - } |
|
| 981 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 982 | + foreach ( $inputs as $input ) { |
|
| 983 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 984 | + unset($input); |
|
| 985 | + } |
|
| 986 | + } |
|
| 987 | 987 | |
| 988 | 988 | /** |
| 989 | 989 | * Check if current field option is an "other" option |
@@ -997,14 +997,14 @@ discard block |
||
| 997 | 997 | return $opt_key && strpos( $opt_key, 'other_' ) === 0; |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | - /** |
|
| 1001 | - * Get value that belongs in "Other" text box |
|
| 1002 | - * |
|
| 1003 | - * @since 2.0.6 |
|
| 1004 | - * |
|
| 1005 | - * @param array $args |
|
| 1006 | - */ |
|
| 1007 | - public static function get_other_val( $args ) { |
|
| 1000 | + /** |
|
| 1001 | + * Get value that belongs in "Other" text box |
|
| 1002 | + * |
|
| 1003 | + * @since 2.0.6 |
|
| 1004 | + * |
|
| 1005 | + * @param array $args |
|
| 1006 | + */ |
|
| 1007 | + public static function get_other_val( $args ) { |
|
| 1008 | 1008 | $defaults = array( |
| 1009 | 1009 | 'opt_key' => 0, |
| 1010 | 1010 | 'field' => array(), |
@@ -1082,20 +1082,20 @@ discard block |
||
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | return $other_val; |
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - /** |
|
| 1088 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1089 | - * Intended for front-end use |
|
| 1090 | - * |
|
| 1091 | - * @since 2.0.6 |
|
| 1092 | - * |
|
| 1093 | - * @param array $args should include field, opt_key and field name |
|
| 1094 | - * @param boolean $other_opt |
|
| 1095 | - * @param string $checked |
|
| 1096 | - * @return string $other_val |
|
| 1097 | - */ |
|
| 1098 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + /** |
|
| 1088 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1089 | + * Intended for front-end use |
|
| 1090 | + * |
|
| 1091 | + * @since 2.0.6 |
|
| 1092 | + * |
|
| 1093 | + * @param array $args should include field, opt_key and field name |
|
| 1094 | + * @param boolean $other_opt |
|
| 1095 | + * @param string $checked |
|
| 1096 | + * @return string $other_val |
|
| 1097 | + */ |
|
| 1098 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1099 | 1099 | //Check if this is an "Other" option |
| 1100 | 1100 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 1101 | 1101 | return; |
@@ -1111,8 +1111,8 @@ discard block |
||
| 1111 | 1111 | $checked = 'checked="checked" '; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - return $other_args; |
|
| 1115 | - } |
|
| 1114 | + return $other_args; |
|
| 1115 | + } |
|
| 1116 | 1116 | |
| 1117 | 1117 | /** |
| 1118 | 1118 | * @param array $args |
@@ -1167,8 +1167,8 @@ discard block |
||
| 1167 | 1167 | * @since 2.0.6 |
| 1168 | 1168 | */ |
| 1169 | 1169 | public static function include_other_input( $args ) { |
| 1170 | - if ( ! $args['other_opt'] ) { |
|
| 1171 | - return; |
|
| 1170 | + if ( ! $args['other_opt'] ) { |
|
| 1171 | + return; |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | $classes = array( 'frm_other_input' ); |
@@ -1187,15 +1187,15 @@ discard block |
||
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | 1189 | /** |
| 1190 | - * Get the HTML id for an "Other" text field |
|
| 1191 | - * Note: This does not affect fields in repeating sections |
|
| 1192 | - * |
|
| 1193 | - * @since 2.0.08 |
|
| 1194 | - * @param string $type - field type |
|
| 1195 | - * @param string $html_id |
|
| 1196 | - * @param string|boolean $opt_key |
|
| 1197 | - * @return string $other_id |
|
| 1198 | - */ |
|
| 1190 | + * Get the HTML id for an "Other" text field |
|
| 1191 | + * Note: This does not affect fields in repeating sections |
|
| 1192 | + * |
|
| 1193 | + * @since 2.0.08 |
|
| 1194 | + * @param string $type - field type |
|
| 1195 | + * @param string $html_id |
|
| 1196 | + * @param string|boolean $opt_key |
|
| 1197 | + * @return string $other_id |
|
| 1198 | + */ |
|
| 1199 | 1199 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1200 | 1200 | $other_id = $html_id; |
| 1201 | 1201 | |
@@ -1259,10 +1259,10 @@ discard block |
||
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | public static function switch_field_ids( $val ) { |
| 1262 | - global $frm_duplicate_ids; |
|
| 1263 | - $replace = array(); |
|
| 1264 | - $replace_with = array(); |
|
| 1265 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1262 | + global $frm_duplicate_ids; |
|
| 1263 | + $replace = array(); |
|
| 1264 | + $replace_with = array(); |
|
| 1265 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1266 | 1266 | $replace[] = '[if ' . $old . ']'; |
| 1267 | 1267 | $replace_with[] = '[if ' . $new . ']'; |
| 1268 | 1268 | $replace[] = '[if ' . $old . ' '; |
@@ -1277,19 +1277,19 @@ discard block |
||
| 1277 | 1277 | $replace_with[] = '[' . $new . ']'; |
| 1278 | 1278 | $replace[] = '[' . $old . ' '; |
| 1279 | 1279 | $replace_with[] = '[' . $new . ' '; |
| 1280 | - unset($old, $new); |
|
| 1281 | - } |
|
| 1280 | + unset($old, $new); |
|
| 1281 | + } |
|
| 1282 | 1282 | if ( is_array( $val ) ) { |
| 1283 | 1283 | foreach ( $val as $k => $v ) { |
| 1284 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1285 | - unset($k, $v); |
|
| 1286 | - } |
|
| 1287 | - } else { |
|
| 1288 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1289 | - } |
|
| 1284 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1285 | + unset($k, $v); |
|
| 1286 | + } |
|
| 1287 | + } else { |
|
| 1288 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1289 | + } |
|
| 1290 | 1290 | |
| 1291 | - return $val; |
|
| 1292 | - } |
|
| 1291 | + return $val; |
|
| 1292 | + } |
|
| 1293 | 1293 | |
| 1294 | 1294 | public static function get_us_states() { |
| 1295 | 1295 | return apply_filters( 'frm_us_states', array( |
@@ -1349,21 +1349,21 @@ discard block |
||
| 1349 | 1349 | |
| 1350 | 1350 | public static function get_countries() { |
| 1351 | 1351 | return apply_filters( 'frm_countries', array( __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), __( 'Zimbabwe', 'formidable' ), |
| 1352 | - ) ); |
|
| 1353 | - } |
|
| 1352 | + ) ); |
|
| 1353 | + } |
|
| 1354 | 1354 | |
| 1355 | 1355 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1356 | 1356 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1357 | 1357 | |
| 1358 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1359 | - $state_abv = array_keys($states); |
|
| 1360 | - sort($state_abv); |
|
| 1358 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1359 | + $state_abv = array_keys($states); |
|
| 1360 | + sort($state_abv); |
|
| 1361 | 1361 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1362 | 1362 | |
| 1363 | - $states = array_values($states); |
|
| 1364 | - sort($states); |
|
| 1363 | + $states = array_values($states); |
|
| 1364 | + sort($states); |
|
| 1365 | 1365 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1366 | - unset($state_abv, $states); |
|
| 1366 | + unset($state_abv, $states); |
|
| 1367 | 1367 | |
| 1368 | 1368 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1369 | 1369 | __( 'Under 18', 'formidable' ), |
@@ -1404,7 +1404,7 @@ discard block |
||
| 1404 | 1404 | ); |
| 1405 | 1405 | |
| 1406 | 1406 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1407 | - } |
|
| 1407 | + } |
|
| 1408 | 1408 | |
| 1409 | 1409 | /** |
| 1410 | 1410 | * Display a field value selector |
@@ -1414,10 +1414,10 @@ discard block |
||
| 1414 | 1414 | * @param int $selector_field_id |
| 1415 | 1415 | * @param array $selector_args |
| 1416 | 1416 | */ |
| 1417 | - public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1418 | - $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1419 | - $field_value_selector->display(); |
|
| 1420 | - } |
|
| 1417 | + public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1418 | + $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1419 | + $field_value_selector->display(); |
|
| 1420 | + } |
|
| 1421 | 1421 | |
| 1422 | 1422 | /** |
| 1423 | 1423 | * Convert a field object to a flat array |
@@ -1470,10 +1470,10 @@ discard block |
||
| 1470 | 1470 | return FrmField::is_required( $field ); |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | - public static function maybe_get_field( &$field ) { |
|
| 1473 | + public static function maybe_get_field( &$field ) { |
|
| 1474 | 1474 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
| 1475 | 1475 | FrmField::maybe_get_field( $field ); |
| 1476 | - } |
|
| 1476 | + } |
|
| 1477 | 1477 | |
| 1478 | 1478 | public static function dropdown_categories( $args ) { |
| 1479 | 1479 | _deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' ); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 10 | + if ( strpos( $type, '|' ) ) { |
|
| 11 | + list( $type, $setting ) = explode( '|', $type ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 14 | + $defaults = self::get_default_field_opts( $type, $form_id ); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html( $type ); |
|
| 16 | 16 | |
| 17 | 17 | $values = array(); |
| 18 | 18 | |
@@ -20,20 +20,20 @@ discard block |
||
| 20 | 20 | if ( $var == 'field_options' ) { |
| 21 | 21 | $values['field_options'] = array(); |
| 22 | 22 | foreach ( $default as $opt_var => $opt_default ) { |
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 23 | + $values['field_options'][$opt_var] = $opt_default; |
|
| 24 | + unset( $opt_var, $opt_default ); |
|
| 25 | 25 | } |
| 26 | 26 | } else { |
| 27 | - $values[ $var ] = $default; |
|
| 27 | + $values[$var] = $default; |
|
| 28 | 28 | } |
| 29 | - unset($var, $default); |
|
| 29 | + unset( $var, $default ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ( isset( $setting ) && ! empty( $setting ) ) { |
| 33 | 33 | if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
| 34 | 34 | $values['field_options']['data_type'] = $setting; |
| 35 | 35 | } else { |
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 36 | + $values['field_options'][$setting] = 1; |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $fields = FrmField::field_selection(); |
| 61 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 61 | + $fields = array_merge( $fields, FrmField::pro_field_selection() ); |
|
| 62 | 62 | |
| 63 | - if ( isset( $fields[ $type ] ) ) { |
|
| 64 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 63 | + if ( isset( $fields[$type] ) ) { |
|
| 64 | + $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type]; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - unset($fields); |
|
| 67 | + unset( $fields ); |
|
| 68 | 68 | |
| 69 | 69 | return $values; |
| 70 | 70 | } |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | $values['form_name'] = ''; |
| 94 | 94 | } else { |
| 95 | 95 | foreach ( $defaults as $var => $default ) { |
| 96 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 97 | - unset($var, $default); |
|
| 96 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 97 | + unset( $var, $default ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $values['options'] = $record->options; |
| 106 | 106 | $values['field_options'] = $record->field_options; |
| 107 | 107 | |
| 108 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 108 | + $defaults = self::get_default_field_opts( $values['type'], $record, true ); |
|
| 109 | 109 | |
| 110 | 110 | if ( $values['type'] == 'captcha' ) { |
| 111 | 111 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | foreach ( $defaults as $opt => $default ) { |
| 116 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 117 | - unset($opt, $default); |
|
| 116 | + $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default; |
|
| 117 | + unset( $opt, $default ); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type ); |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 176 | 176 | $values['form_id'] = $form_id; |
| 177 | - $values['options'] = maybe_serialize($field->options); |
|
| 178 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 177 | + $values['options'] = maybe_serialize( $field->options ); |
|
| 178 | + $values['default_value'] = maybe_serialize( $field->default_value ); |
|
| 179 | 179 | |
| 180 | 180 | foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
| 181 | - $values[ $col ] = $field->{$col}; |
|
| 181 | + $values[$col] = $field->{$col}; |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | $defaults = array( |
| 195 | 195 | 'unique_msg' => array( |
| 196 | 196 | 'full' => $default_settings['unique_msg'], |
| 197 | - 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ), |
|
| 197 | + 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ), |
|
| 198 | 198 | ), |
| 199 | 199 | 'invalid' => array( |
| 200 | 200 | 'full' => __( 'This field is invalid', 'formidable' ), |
| 201 | - 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ), |
|
| 201 | + 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ), |
|
| 202 | 202 | ), |
| 203 | 203 | 'blank' => array( |
| 204 | 204 | 'full' => $frm_settings->blank_msg, |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | ); |
| 212 | 212 | |
| 213 | 213 | $msg = FrmField::get_option( $field, $error ); |
| 214 | - $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg; |
|
| 214 | + $msg = empty( $msg ) ? $defaults[$error]['part'] : $msg; |
|
| 215 | 215 | $msg = do_shortcode( $msg ); |
| 216 | 216 | return $msg; |
| 217 | 217 | } |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | </div> |
| 242 | 242 | DEFAULT_HTML; |
| 243 | 243 | } else { |
| 244 | - $default_html = apply_filters('frm_other_custom_html', '', $type); |
|
| 244 | + $default_html = apply_filters( 'frm_other_custom_html', '', $type ); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 247 | + return apply_filters( 'frm_custom_html', $default_html, $type ); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 251 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 251 | + $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form ); |
|
| 252 | 252 | |
| 253 | 253 | $defaults = array( |
| 254 | 254 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
@@ -256,42 +256,42 @@ discard block |
||
| 256 | 256 | 'field_plus_id' => '', |
| 257 | 257 | 'section_id' => '', |
| 258 | 258 | ); |
| 259 | - $args = wp_parse_args($args, $defaults); |
|
| 259 | + $args = wp_parse_args( $args, $defaults ); |
|
| 260 | 260 | $field_name = $args['field_name']; |
| 261 | 261 | $field_id = $args['field_id']; |
| 262 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 262 | + $html_id = self::get_html_id( $field, $args['field_plus_id'] ); |
|
| 263 | 263 | |
| 264 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 264 | + if ( FrmField::is_multiple_select( $field ) ) { |
|
| 265 | 265 | $field_name .= '[]'; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | //replace [id] |
| 269 | - $html = str_replace('[id]', $field_id, $html); |
|
| 269 | + $html = str_replace( '[id]', $field_id, $html ); |
|
| 270 | 270 | |
| 271 | 271 | // Remove the for attribute for captcha |
| 272 | 272 | if ( $field['type'] == 'captcha' ) { |
| 273 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 273 | + $html = str_replace( ' for="field_[key]"', '', $html ); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // set the label for |
| 277 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 277 | + $html = str_replace( 'field_[key]', $html_id, $html ); |
|
| 278 | 278 | |
| 279 | 279 | //replace [key] |
| 280 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 280 | + $html = str_replace( '[key]', $field['field_key'], $html ); |
|
| 281 | 281 | |
| 282 | 282 | //replace [description] and [required_label] and [error] |
| 283 | 283 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 284 | 284 | if ( ! is_array( $errors ) ) { |
| 285 | 285 | $errors = array(); |
| 286 | 286 | } |
| 287 | - $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
|
| 287 | + $error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false; |
|
| 288 | 288 | |
| 289 | 289 | //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
| 290 | 290 | if ( $field['type'] == 'divider' ) { |
| 291 | 291 | if ( FrmField::is_option_true( $field, 'description' ) ) { |
| 292 | 292 | $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
| 293 | 293 | } else { |
| 294 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 294 | + $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html ); |
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | |
@@ -306,40 +306,40 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | //replace [required_class] |
| 308 | 308 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 309 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 309 | + $html = str_replace( '[required_class]', $required_class, $html ); |
|
| 310 | 310 | |
| 311 | 311 | //replace [label_position] |
| 312 | 312 | $field['label'] = self::label_position( $field['label'], $field, $form ); |
| 313 | 313 | self::add_class_to_label( $field, $html ); |
| 314 | 314 | |
| 315 | 315 | //replace [field_name] |
| 316 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 316 | + $html = str_replace( '[field_name]', $field['name'], $html ); |
|
| 317 | 317 | |
| 318 | 318 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
| 319 | 319 | |
| 320 | 320 | //replace [entry_key] |
| 321 | 321 | $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
| 322 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 322 | + $html = str_replace( '[entry_key]', $entry_key, $html ); |
|
| 323 | 323 | |
| 324 | 324 | if ( $form ) { |
| 325 | 325 | $form = (array) $form; |
| 326 | 326 | |
| 327 | 327 | //replace [form_key] |
| 328 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 328 | + $html = str_replace( '[form_key]', $form['form_key'], $html ); |
|
| 329 | 329 | |
| 330 | 330 | //replace [form_name] |
| 331 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 331 | + $html = str_replace( '[form_name]', $form['name'], $html ); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | self::process_wp_shortcodes( $html ); |
| 335 | 335 | |
| 336 | 336 | //replace [input] |
| 337 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 337 | + preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER ); |
|
| 338 | 338 | global $frm_vars; |
| 339 | 339 | $frm_settings = FrmAppHelper::get_settings(); |
| 340 | 340 | |
| 341 | 341 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 342 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 342 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
| 343 | 343 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( |
| 344 | 344 | 'conditional' => false, |
| 345 | 345 | 'conditional_check' => false, |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | $replace_with = ''; |
| 349 | 349 | |
| 350 | 350 | if ( $tag == 'input' ) { |
| 351 | - if ( isset($atts['opt']) ) { |
|
| 352 | - $atts['opt']--; |
|
| 351 | + if ( isset( $atts['opt'] ) ) { |
|
| 352 | + $atts['opt'] --; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 356 | - if ( isset($atts['class']) ) { |
|
| 357 | - unset($atts['class']); |
|
| 355 | + $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : ''; |
|
| 356 | + if ( isset( $atts['class'] ) ) { |
|
| 357 | + unset( $atts['class'] ); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $field['shortcodes'] = $atts; |
@@ -363,16 +363,16 @@ discard block |
||
| 363 | 363 | $replace_with = ob_get_contents(); |
| 364 | 364 | ob_end_clean(); |
| 365 | 365 | } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
| 366 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 366 | + $replace_with = FrmProEntriesController::entry_delete_link( $atts ); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 369 | + $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html ); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | $html .= "\n"; |
| 373 | 373 | |
| 374 | 374 | //Return html if conf_field to prevent loop |
| 375 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 375 | + if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) { |
|
| 376 | 376 | return $html; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -488,14 +488,14 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | private static function get_field_div_classes( $field_id, $field, $errors, $html ) { |
| 490 | 490 | // Add error class |
| 491 | - $classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
|
| 491 | + $classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : ''; |
|
| 492 | 492 | |
| 493 | 493 | // Add label position class |
| 494 | 494 | $classes .= ' frm_' . $field['label'] . '_container'; |
| 495 | 495 | |
| 496 | 496 | // Add CSS layout classes |
| 497 | 497 | if ( ! empty( $field['classes'] ) ) { |
| 498 | - if ( ! strpos( $html, 'frm_form_field ') ) { |
|
| 498 | + if ( ! strpos( $html, 'frm_form_field ' ) ) { |
|
| 499 | 499 | $classes .= ' frm_form_field'; |
| 500 | 500 | } |
| 501 | 501 | $classes .= ' ' . $field['classes']; |
@@ -538,15 +538,15 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | $with_tags = $args['conditional_check'] ? 3 : 2; |
| 541 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 542 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 543 | - $tag = str_replace(']', '', $tag); |
|
| 544 | - $tags = explode(' ', $tag); |
|
| 545 | - if ( is_array($tags) ) { |
|
| 541 | + if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) { |
|
| 542 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] ); |
|
| 543 | + $tag = str_replace( ']', '', $tag ); |
|
| 544 | + $tags = explode( ' ', $tag ); |
|
| 545 | + if ( is_array( $tags ) ) { |
|
| 546 | 546 | $tag = $tags[0]; |
| 547 | 547 | } |
| 548 | 548 | } else { |
| 549 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 549 | + $tag = $shortcodes[$with_tags - 1][$short_key]; |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | return $tag; |
@@ -602,10 +602,10 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | public static function show_single_option( $field ) { |
| 604 | 604 | $field_name = $field['name']; |
| 605 | - $html_id = self::get_html_id($field); |
|
| 605 | + $html_id = self::get_html_id( $field ); |
|
| 606 | 606 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 607 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 608 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 607 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 608 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 609 | 609 | |
| 610 | 610 | // If this is an "Other" option, get the HTML for it |
| 611 | 611 | if ( self::is_other_opt( $opt_key ) ) { |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | public static function get_term_link( $tax_id ) { |
| 622 | - $tax = get_taxonomy($tax_id); |
|
| 622 | + $tax = get_taxonomy( $tax_id ); |
|
| 623 | 623 | if ( ! $tax ) { |
| 624 | 624 | return; |
| 625 | 625 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
| 629 | 629 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 630 | 630 | ); |
| 631 | - unset($tax); |
|
| 631 | + unset( $tax ); |
|
| 632 | 632 | |
| 633 | 633 | return $link; |
| 634 | 634 | } |
@@ -637,8 +637,8 @@ discard block |
||
| 637 | 637 | $hide_opt = self::get_value_for_comparision( $hide_opt ); |
| 638 | 638 | $observed_value = self::get_value_for_comparision( $observed_value ); |
| 639 | 639 | |
| 640 | - if ( is_array($observed_value) ) { |
|
| 641 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 640 | + if ( is_array( $observed_value ) ) { |
|
| 641 | + return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | $m = false; |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | } else if ( $cond == '<' ) { |
| 652 | 652 | $m = $observed_value < $hide_opt; |
| 653 | 653 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 654 | - $m = stripos($observed_value, $hide_opt); |
|
| 654 | + $m = stripos( $observed_value, $hide_opt ); |
|
| 655 | 655 | if ( $cond == 'not LIKE' ) { |
| 656 | 656 | $m = ( $m === false ) ? true : false; |
| 657 | 657 | } else { |
@@ -677,23 +677,23 @@ discard block |
||
| 677 | 677 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 678 | 678 | $m = false; |
| 679 | 679 | if ( $cond == '==' ) { |
| 680 | - if ( is_array($hide_opt) ) { |
|
| 681 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 682 | - $m = empty($m) ? false : true; |
|
| 680 | + if ( is_array( $hide_opt ) ) { |
|
| 681 | + $m = array_intersect( $hide_opt, $observed_value ); |
|
| 682 | + $m = empty( $m ) ? false : true; |
|
| 683 | 683 | } else { |
| 684 | - $m = in_array($hide_opt, $observed_value); |
|
| 684 | + $m = in_array( $hide_opt, $observed_value ); |
|
| 685 | 685 | } |
| 686 | 686 | } else if ( $cond == '!=' ) { |
| 687 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 687 | + $m = ! in_array( $hide_opt, $observed_value ); |
|
| 688 | 688 | } else if ( $cond == '>' ) { |
| 689 | - $min = min($observed_value); |
|
| 689 | + $min = min( $observed_value ); |
|
| 690 | 690 | $m = $min > $hide_opt; |
| 691 | 691 | } else if ( $cond == '<' ) { |
| 692 | - $max = max($observed_value); |
|
| 692 | + $max = max( $observed_value ); |
|
| 693 | 693 | $m = $max < $hide_opt; |
| 694 | 694 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 695 | 695 | foreach ( $observed_value as $ob ) { |
| 696 | - $m = strpos($ob, $hide_opt); |
|
| 696 | + $m = strpos( $ob, $hide_opt ); |
|
| 697 | 697 | if ( $m !== false ) { |
| 698 | 698 | $m = true; |
| 699 | 699 | break; |
@@ -714,20 +714,20 @@ discard block |
||
| 714 | 714 | * @return string |
| 715 | 715 | */ |
| 716 | 716 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 717 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 717 | + if ( strpos( $value, '[sitename]' ) !== false ) { |
|
| 718 | 718 | $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
| 719 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 719 | + $value = str_replace( '[sitename]', $new_value, $value ); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 723 | - $value = do_shortcode($value); |
|
| 722 | + $value = apply_filters( 'frm_content', $value, $form, $entry ); |
|
| 723 | + $value = do_shortcode( $value ); |
|
| 724 | 724 | |
| 725 | 725 | return $value; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | public static function get_shortcodes( $content, $form_id ) { |
| 729 | 729 | if ( FrmAppHelper::pro_is_installed() ) { |
| 730 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 730 | + return FrmProDisplaysHelper::get_shortcodes( $content, $form_id ); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | $fields = FrmField::getAll( array( |
@@ -735,9 +735,9 @@ discard block |
||
| 735 | 735 | 'fi.type not' => FrmField::no_save_fields(), |
| 736 | 736 | ) ); |
| 737 | 737 | |
| 738 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 738 | + $tagregexp = self::allowed_shortcodes( $fields ); |
|
| 739 | 739 | |
| 740 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 740 | + preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER ); |
|
| 741 | 741 | |
| 742 | 742 | return $matches; |
| 743 | 743 | } |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | $tagregexp[] = $field->field_key; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - $tagregexp = implode('|', $tagregexp); |
|
| 753 | + $tagregexp = implode( '|', $tagregexp ); |
|
| 754 | 754 | return $tagregexp; |
| 755 | 755 | } |
| 756 | 756 | |
@@ -766,28 +766,28 @@ discard block |
||
| 766 | 766 | continue; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 769 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] ); |
|
| 770 | 770 | |
| 771 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 772 | - $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
|
| 773 | - $tags = explode(' ', $tag); |
|
| 774 | - if ( is_array($tags) ) { |
|
| 771 | + if ( ! empty( $shortcodes[3][$short_key] ) ) { |
|
| 772 | + $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] ); |
|
| 773 | + $tags = explode( ' ', $tag ); |
|
| 774 | + if ( is_array( $tags ) ) { |
|
| 775 | 775 | $tag = $tags[0]; |
| 776 | 776 | } |
| 777 | 777 | } else { |
| 778 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 778 | + $tag = $shortcodes[2][$short_key]; |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | switch ( $tag ) { |
| 782 | 782 | case 'id': |
| 783 | 783 | case 'key': |
| 784 | 784 | case 'ip': |
| 785 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 785 | + $replace_with = $shortcode_values[$tag]; |
|
| 786 | 786 | break; |
| 787 | 787 | |
| 788 | 788 | case 'user_agent': |
| 789 | 789 | case 'user-agent': |
| 790 | - $entry->description = maybe_unserialize($entry->description); |
|
| 790 | + $entry->description = maybe_unserialize( $entry->description ); |
|
| 791 | 791 | $replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] ); |
| 792 | 792 | break; |
| 793 | 793 | |
@@ -795,25 +795,25 @@ discard block |
||
| 795 | 795 | case 'created-at': |
| 796 | 796 | case 'updated_at': |
| 797 | 797 | case 'updated-at': |
| 798 | - if ( isset($atts['format']) ) { |
|
| 798 | + if ( isset( $atts['format'] ) ) { |
|
| 799 | 799 | $time_format = ' '; |
| 800 | 800 | } else { |
| 801 | - $atts['format'] = get_option('date_format'); |
|
| 801 | + $atts['format'] = get_option( 'date_format' ); |
|
| 802 | 802 | $time_format = ''; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - $this_tag = str_replace('-', '_', $tag); |
|
| 806 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 807 | - unset($this_tag); |
|
| 805 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 806 | + $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format ); |
|
| 807 | + unset( $this_tag ); |
|
| 808 | 808 | break; |
| 809 | 809 | |
| 810 | 810 | case 'created_by': |
| 811 | 811 | case 'created-by': |
| 812 | 812 | case 'updated_by': |
| 813 | 813 | case 'updated-by': |
| 814 | - $this_tag = str_replace('-', '_', $tag); |
|
| 814 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 815 | 815 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 816 | - unset($this_tag); |
|
| 816 | + unset( $this_tag ); |
|
| 817 | 817 | break; |
| 818 | 818 | |
| 819 | 819 | case 'admin_email': |
@@ -830,16 +830,16 @@ discard block |
||
| 830 | 830 | break; |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 833 | + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
|
| 834 | 834 | |
| 835 | 835 | $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
| 836 | 836 | |
| 837 | 837 | $atts['entry_id'] = $entry->id; |
| 838 | 838 | $atts['entry_key'] = $entry->item_key; |
| 839 | 839 | |
| 840 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 840 | + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) { |
|
| 841 | 841 | $replace_with = $field->name; |
| 842 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 842 | + } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) { |
|
| 843 | 843 | $replace_with = $field->description; |
| 844 | 844 | } else { |
| 845 | 845 | $string_value = $replace_with; |
@@ -854,14 +854,14 @@ discard block |
||
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | - unset($field); |
|
| 857 | + unset( $field ); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - if ( isset($replace_with) ) { |
|
| 861 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 860 | + if ( isset( $replace_with ) ) { |
|
| 861 | + $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content ); |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | - unset($atts, $conditional, $replace_with); |
|
| 864 | + unset( $atts, $conditional, $replace_with ); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | return $content; |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | $new_value = ''; |
| 878 | 878 | switch ( $tag ) { |
| 879 | 879 | case 'admin_email': |
| 880 | - $new_value = get_option('admin_email'); |
|
| 880 | + $new_value = get_option( 'admin_email' ); |
|
| 881 | 881 | break; |
| 882 | 882 | case 'siteurl': |
| 883 | 883 | $new_value = FrmAppHelper::site_url(); |
@@ -903,28 +903,28 @@ discard block |
||
| 903 | 903 | * @return string|array |
| 904 | 904 | */ |
| 905 | 905 | public static function process_get_shortcode( $atts, $return_array = false ) { |
| 906 | - if ( ! isset($atts['param']) ) { |
|
| 906 | + if ( ! isset( $atts['param'] ) ) { |
|
| 907 | 907 | return ''; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - if ( strpos($atts['param'], '[') ) { |
|
| 911 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 912 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 910 | + if ( strpos( $atts['param'], '[' ) ) { |
|
| 911 | + $atts['param'] = str_replace( '[', '[', $atts['param'] ); |
|
| 912 | + $atts['param'] = str_replace( ']', ']', $atts['param'] ); |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' ); |
| 916 | 916 | $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
| 917 | 917 | |
| 918 | 918 | if ( $new_value == '' ) { |
| 919 | - if ( ! isset($atts['prev_val']) ) { |
|
| 919 | + if ( ! isset( $atts['prev_val'] ) ) { |
|
| 920 | 920 | $atts['prev_val'] = ''; |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 923 | + $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; |
|
| 924 | 924 | } |
| 925 | 925 | |
| 926 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 927 | - $new_value = implode(', ', $new_value); |
|
| 926 | + if ( is_array( $new_value ) && ! $return_array ) { |
|
| 927 | + $new_value = implode( ', ', $new_value ); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | return $new_value; |
@@ -937,17 +937,17 @@ discard block |
||
| 937 | 937 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 938 | 938 | |
| 939 | 939 | if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
| 940 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 941 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 942 | - if ( is_array($replace_with) ) { |
|
| 943 | - $replace_with = implode("\n", $replace_with); |
|
| 940 | + $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true; |
|
| 941 | + if ( apply_filters( 'frm_use_wpautop', $autop ) ) { |
|
| 942 | + if ( is_array( $replace_with ) ) { |
|
| 943 | + $replace_with = implode( "\n", $replace_with ); |
|
| 944 | 944 | } |
| 945 | - $replace_with = wpautop($replace_with); |
|
| 945 | + $replace_with = wpautop( $replace_with ); |
|
| 946 | 946 | } |
| 947 | 947 | unset( $autop ); |
| 948 | 948 | } else if ( is_array( $replace_with ) ) { |
| 949 | - if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[ $atts['show'] ] ) ) { |
|
| 950 | - $replace_with = $replace_with[ $atts['show'] ]; |
|
| 949 | + if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[$atts['show']] ) ) { |
|
| 950 | + $replace_with = $replace_with[$atts['show']]; |
|
| 951 | 951 | } else { |
| 952 | 952 | $replace_with = implode( $sep, $replace_with ); |
| 953 | 953 | } |
@@ -964,14 +964,14 @@ discard block |
||
| 964 | 964 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 965 | 965 | |
| 966 | 966 | $field_types = array(); |
| 967 | - if ( in_array($type, $single_input) ) { |
|
| 967 | + if ( in_array( $type, $single_input ) ) { |
|
| 968 | 968 | self::field_types_for_input( $single_input, $field_selection, $field_types ); |
| 969 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 969 | + } else if ( in_array( $type, $multiple_input ) ) { |
|
| 970 | 970 | self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
| 971 | - } else if ( in_array($type, $other_type) ) { |
|
| 971 | + } else if ( in_array( $type, $other_type ) ) { |
|
| 972 | 972 | self::field_types_for_input( $other_type, $field_selection, $field_types ); |
| 973 | - } else if ( isset( $field_selection[ $type ] ) ) { |
|
| 974 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 973 | + } else if ( isset( $field_selection[$type] ) ) { |
|
| 974 | + $field_types[$type] = $field_selection[$type]; |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
@@ -980,8 +980,8 @@ discard block |
||
| 980 | 980 | |
| 981 | 981 | private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
| 982 | 982 | foreach ( $inputs as $input ) { |
| 983 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 984 | - unset($input); |
|
| 983 | + $field_types[$input] = $fields[$input]; |
|
| 984 | + unset( $input ); |
|
| 985 | 985 | } |
| 986 | 986 | } |
| 987 | 987 | |
@@ -1028,21 +1028,21 @@ discard block |
||
| 1028 | 1028 | // Check posted vals before checking saved values |
| 1029 | 1029 | |
| 1030 | 1030 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 1031 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { |
|
| 1031 | + if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { |
|
| 1032 | 1032 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1033 | - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 1033 | + $other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : ''; |
|
| 1034 | 1034 | } else { |
| 1035 | - $other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ); |
|
| 1035 | + $other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | return $other_val; |
| 1038 | 1038 | |
| 1039 | - } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { |
|
| 1039 | + } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { |
|
| 1040 | 1040 | // For normal fields |
| 1041 | 1041 | |
| 1042 | 1042 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1043 | - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 1043 | + $other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : ''; |
|
| 1044 | 1044 | } else { |
| 1045 | - $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] ); |
|
| 1045 | + $other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] ); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | return $other_val; |
| 1048 | 1048 | } |
@@ -1051,8 +1051,8 @@ discard block |
||
| 1051 | 1051 | if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { |
| 1052 | 1052 | // Check if there is an "other" val in saved value and make sure the |
| 1053 | 1053 | // "other" val is not equal to the Other checkbox option |
| 1054 | - if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
|
| 1055 | - $other_val = $field['value'][ $opt_key ]; |
|
| 1054 | + if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) { |
|
| 1055 | + $other_val = $field['value'][$opt_key]; |
|
| 1056 | 1056 | } |
| 1057 | 1057 | } else { |
| 1058 | 1058 | /** |
@@ -1064,8 +1064,8 @@ discard block |
||
| 1064 | 1064 | // Multi-select dropdowns - key is not preserved |
| 1065 | 1065 | if ( is_array( $field['value'] ) ) { |
| 1066 | 1066 | $o_key = array_search( $temp_val, $field['value'] ); |
| 1067 | - if ( isset( $field['value'][ $o_key ] ) ) { |
|
| 1068 | - unset( $field['value'][ $o_key ], $o_key ); |
|
| 1067 | + if ( isset( $field['value'][$o_key] ) ) { |
|
| 1068 | + unset( $field['value'][$o_key], $o_key ); |
|
| 1069 | 1069 | } |
| 1070 | 1070 | } else if ( $temp_val == $field['value'] ) { |
| 1071 | 1071 | // For radio and regular dropdowns |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | private static function set_other_name( $args, &$other_args ) { |
| 1123 | 1123 | //Set up name for other field |
| 1124 | 1124 | $other_args['name'] = str_replace( '[]', '', $args['field_name'] ); |
| 1125 | - $other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']); |
|
| 1125 | + $other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] ); |
|
| 1126 | 1126 | $other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']'; |
| 1127 | 1127 | |
| 1128 | 1128 | //Converts item_meta[field_id] => item_meta[other][field_id] and |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | // Count should only be greater than 3 if inside of a repeating section |
| 1150 | 1150 | if ( count( $temp_array ) > 3 ) { |
| 1151 | 1151 | $parent = str_replace( ']', '', $temp_array[1] ); |
| 1152 | - $pointer = str_replace( ']', '', $temp_array[2]); |
|
| 1152 | + $pointer = str_replace( ']', '', $temp_array[2] ); |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | // Get text for "other" text field |
@@ -1277,15 +1277,15 @@ discard block |
||
| 1277 | 1277 | $replace_with[] = '[' . $new . ']'; |
| 1278 | 1278 | $replace[] = '[' . $old . ' '; |
| 1279 | 1279 | $replace_with[] = '[' . $new . ' '; |
| 1280 | - unset($old, $new); |
|
| 1280 | + unset( $old, $new ); |
|
| 1281 | 1281 | } |
| 1282 | 1282 | if ( is_array( $val ) ) { |
| 1283 | 1283 | foreach ( $val as $k => $v ) { |
| 1284 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1285 | - unset($k, $v); |
|
| 1284 | + $val[$k] = str_replace( $replace, $replace_with, $v ); |
|
| 1285 | + unset( $k, $v ); |
|
| 1286 | 1286 | } |
| 1287 | 1287 | } else { |
| 1288 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1288 | + $val = str_replace( $replace, $replace_with, $val ); |
|
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | return $val; |
@@ -1348,24 +1348,24 @@ discard block |
||
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | 1350 | public static function get_countries() { |
| 1351 | - return apply_filters( 'frm_countries', array( __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), __( 'Zimbabwe', 'formidable' ), |
|
| 1351 | + return apply_filters( 'frm_countries', array( __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), __( 'Zimbabwe', 'formidable' ), |
|
| 1352 | 1352 | ) ); |
| 1353 | 1353 | } |
| 1354 | 1354 | |
| 1355 | 1355 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1356 | - $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
|
| 1356 | + $prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries(); |
|
| 1357 | 1357 | |
| 1358 | 1358 | $states = FrmFieldsHelper::get_us_states(); |
| 1359 | - $state_abv = array_keys($states); |
|
| 1360 | - sort($state_abv); |
|
| 1361 | - $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
|
| 1359 | + $state_abv = array_keys( $states ); |
|
| 1360 | + sort( $state_abv ); |
|
| 1361 | + $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv; |
|
| 1362 | 1362 | |
| 1363 | - $states = array_values($states); |
|
| 1364 | - sort($states); |
|
| 1365 | - $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
|
| 1366 | - unset($state_abv, $states); |
|
| 1363 | + $states = array_values( $states ); |
|
| 1364 | + sort( $states ); |
|
| 1365 | + $prepop[__( 'U.S. States', 'formidable' )] = $states; |
|
| 1366 | + unset( $state_abv, $states ); |
|
| 1367 | 1367 | |
| 1368 | - $prepop[ __( 'Age', 'formidable' ) ] = array( |
|
| 1368 | + $prepop[__( 'Age', 'formidable' )] = array( |
|
| 1369 | 1369 | __( 'Under 18', 'formidable' ), |
| 1370 | 1370 | __( '18-24', 'formidable' ), |
| 1371 | 1371 | __( '25-34', 'formidable' ), |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | __( 'Prefer Not to Answer', 'formidable' ), |
| 1377 | 1377 | ); |
| 1378 | 1378 | |
| 1379 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
|
| 1379 | + $prepop[__( 'Satisfaction', 'formidable' )] = array( |
|
| 1380 | 1380 | __( 'Very Satisfied', 'formidable' ), |
| 1381 | 1381 | __( 'Satisfied', 'formidable' ), |
| 1382 | 1382 | __( 'Neutral', 'formidable' ), |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | __( 'N/A', 'formidable' ), |
| 1386 | 1386 | ); |
| 1387 | 1387 | |
| 1388 | - $prepop[ __( 'Importance', 'formidable' ) ] = array( |
|
| 1388 | + $prepop[__( 'Importance', 'formidable' )] = array( |
|
| 1389 | 1389 | __( 'Very Important', 'formidable' ), |
| 1390 | 1390 | __( 'Important', 'formidable' ), |
| 1391 | 1391 | __( 'Neutral', 'formidable' ), |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | __( 'N/A', 'formidable' ), |
| 1395 | 1395 | ); |
| 1396 | 1396 | |
| 1397 | - $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
|
| 1397 | + $prepop[__( 'Agreement', 'formidable' )] = array( |
|
| 1398 | 1398 | __( 'Strongly Agree', 'formidable' ), |
| 1399 | 1399 | __( 'Agree', 'formidable' ), |
| 1400 | 1400 | __( 'Neutral', 'formidable' ), |
@@ -6,10 +6,10 @@ discard block |
||
| 6 | 6 | protected $field; |
| 7 | 7 | |
| 8 | 8 | public function prepare_items() { |
| 9 | - global $per_page; |
|
| 9 | + global $per_page; |
|
| 10 | 10 | |
| 11 | 11 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); |
| 12 | - $form_id = $this->params['form']; |
|
| 12 | + $form_id = $this->params['form']; |
|
| 13 | 13 | |
| 14 | 14 | $s_query = array(); |
| 15 | 15 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $limit = FrmDb::esc_limit( $start . ',' . $per_page ); |
| 63 | 63 | $this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query ); |
| 64 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
| 64 | + $total_items = FrmEntry::getRecordCount($s_query); |
|
| 65 | 65 | |
| 66 | 66 | $this->set_pagination_args( array( |
| 67 | 67 | 'total_items' => $total_items, |
@@ -74,18 +74,18 @@ discard block |
||
| 74 | 74 | 'param' => 's', |
| 75 | 75 | 'sanitize' => 'sanitize_text_field', |
| 76 | 76 | ) ); |
| 77 | - if ( ! empty($s) ) { |
|
| 77 | + if ( ! empty($s) ) { |
|
| 78 | 78 | esc_html_e( 'No Entries Found', 'formidable' ); |
| 79 | - return; |
|
| 80 | - } |
|
| 79 | + return; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | $form_id = $this->params['form']; |
| 83 | 83 | $form = $this->params['form']; |
| 84 | 84 | |
| 85 | - if ( $form_id ) { |
|
| 86 | - $form = FrmForm::getOne($form_id); |
|
| 87 | - } |
|
| 88 | - $colspan = $this->get_column_count(); |
|
| 85 | + if ( $form_id ) { |
|
| 86 | + $form = FrmForm::getOne($form_id); |
|
| 87 | + } |
|
| 88 | + $colspan = $this->get_column_count(); |
|
| 89 | 89 | |
| 90 | 90 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
| 91 | 91 | } |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | - * Gets the name of the primary column in the Entries screen |
|
| 109 | - * |
|
| 110 | - * @since 2.0.14 |
|
| 111 | - * |
|
| 112 | - * @return string $primary_column |
|
| 113 | - */ |
|
| 108 | + * Gets the name of the primary column in the Entries screen |
|
| 109 | + * |
|
| 110 | + * @since 2.0.14 |
|
| 111 | + * |
|
| 112 | + * @return string $primary_column |
|
| 113 | + */ |
|
| 114 | 114 | protected function get_primary_column_name() { |
| 115 | 115 | $columns = get_column_headers( $this->screen ); |
| 116 | 116 | $hidden = get_hidden_columns( $this->screen ); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $this->get_actions( $actions, $item, $view_link ); |
| 136 | 136 | |
| 137 | - $action_links = $this->row_actions( $actions ); |
|
| 137 | + $action_links = $this->row_actions( $actions ); |
|
| 138 | 138 | |
| 139 | 139 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 140 | 140 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $r = "<tr id='item-action-{$item->id}'$style>"; |
| 143 | 143 | |
| 144 | 144 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
| 145 | - $action_col = false; |
|
| 145 | + $action_col = false; |
|
| 146 | 146 | |
| 147 | 147 | foreach ( $columns as $column_name => $column_display_name ) { |
| 148 | 148 | $class = $column_name . ' column-' . $column_name; |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | if ( in_array( $column_name, $hidden ) ) { |
| 155 | 155 | $class .= ' frm_hidden'; |
| 156 | 156 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
| 157 | - $action_col = $column_name; |
|
| 158 | - } |
|
| 157 | + $action_col = $column_name; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | 160 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
| 161 | 161 | unset($class); |
@@ -173,15 +173,15 @@ discard block |
||
| 173 | 173 | $val = $this->column_value( $item ); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $r .= "<td $attributes>"; |
|
| 176 | + $r .= "<td $attributes>"; |
|
| 177 | 177 | if ( $column_name == $action_col ) { |
| 178 | 178 | $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
| 179 | 179 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
| 180 | - $r .= $action_links; |
|
| 180 | + $r .= $action_links; |
|
| 181 | 181 | } else { |
| 182 | - $r .= $val; |
|
| 183 | - } |
|
| 184 | - $r .= '</td>'; |
|
| 182 | + $r .= $val; |
|
| 183 | + } |
|
| 184 | + $r .= '</td>'; |
|
| 185 | 185 | } |
| 186 | 186 | unset($val); |
| 187 | 187 | } |
@@ -234,19 +234,19 @@ discard block |
||
| 234 | 234 | return $val; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * @param string $view_link |
|
| 239 | - */ |
|
| 240 | - private function get_actions( &$actions, $item, $view_link ) { |
|
| 237 | + /** |
|
| 238 | + * @param string $view_link |
|
| 239 | + */ |
|
| 240 | + private function get_actions( &$actions, $item, $view_link ) { |
|
| 241 | 241 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
| 242 | 242 | |
| 243 | - if ( current_user_can('frm_delete_entries') ) { |
|
| 243 | + if ( current_user_can('frm_delete_entries') ) { |
|
| 244 | 244 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
| 245 | 245 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
| 246 | - } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 249 | - } |
|
| 248 | + $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | 251 | private function get_column_value( $item, &$val ) { |
| 252 | 252 | $col_name = $this->column_name; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $limit = FrmDb::esc_limit( $start . ',' . $per_page ); |
| 63 | 63 | $this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query ); |
| 64 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
| 64 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
| 65 | 65 | |
| 66 | 66 | $this->set_pagination_args( array( |
| 67 | 67 | 'total_items' => $total_items, |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | 'param' => 's', |
| 75 | 75 | 'sanitize' => 'sanitize_text_field', |
| 76 | 76 | ) ); |
| 77 | - if ( ! empty($s) ) { |
|
| 77 | + if ( ! empty( $s ) ) { |
|
| 78 | 78 | esc_html_e( 'No Entries Found', 'formidable' ); |
| 79 | 79 | return; |
| 80 | 80 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $form = $this->params['form']; |
| 84 | 84 | |
| 85 | 85 | if ( $form_id ) { |
| 86 | - $form = FrmForm::getOne($form_id); |
|
| 86 | + $form = FrmForm::getOne( $form_id ); |
|
| 87 | 87 | } |
| 88 | 88 | $colspan = $this->get_column_count(); |
| 89 | 89 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $r = "<tr id='item-action-{$item->id}'$style>"; |
| 143 | 143 | |
| 144 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
| 144 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
| 145 | 145 | $action_col = false; |
| 146 | 146 | |
| 147 | 147 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
| 161 | - unset($class); |
|
| 161 | + unset( $class ); |
|
| 162 | 162 | $attributes .= ' data-colname="' . $column_display_name . '"'; |
| 163 | 163 | |
| 164 | 164 | $form_id = $this->params['form'] ? $this->params['form'] : 0; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | $r .= '</td>'; |
| 185 | 185 | } |
| 186 | - unset($val); |
|
| 186 | + unset( $val ); |
|
| 187 | 187 | } |
| 188 | 188 | $r .= '</tr>'; |
| 189 | 189 | |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | private function get_actions( &$actions, $item, $view_link ) { |
| 241 | 241 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
| 242 | 242 | |
| 243 | - if ( current_user_can('frm_delete_entries') ) { |
|
| 243 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
| 244 | 244 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
| 245 | 245 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 248 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | private function get_column_value( $item, &$val ) { |
@@ -33,24 +33,24 @@ discard block |
||
| 33 | 33 | 'styles' => 0, |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - $imported = array( |
|
| 37 | - 'imported' => $defaults, |
|
| 36 | + $imported = array( |
|
| 37 | + 'imported' => $defaults, |
|
| 38 | 38 | 'updated' => $defaults, |
| 39 | 39 | 'forms' => array(), |
| 40 | 40 | 'terms' => array(), |
| 41 | - ); |
|
| 41 | + ); |
|
| 42 | 42 | |
| 43 | - unset($defaults); |
|
| 43 | + unset($defaults); |
|
| 44 | 44 | |
| 45 | 45 | if ( ! defined( 'WP_IMPORTING' ) ) { |
| 46 | - define('WP_IMPORTING', true); |
|
| 47 | - } |
|
| 46 | + define('WP_IMPORTING', true); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | if ( ! class_exists( 'DOMDocument' ) ) { |
| 50 | - return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
| 51 | - } |
|
| 50 | + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $dom = new DOMDocument; |
|
| 53 | + $dom = new DOMDocument; |
|
| 54 | 54 | $success = $dom->loadXML( file_get_contents( $file ) ); |
| 55 | 55 | if ( ! $success ) { |
| 56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
@@ -68,45 +68,45 @@ discard block |
||
| 68 | 68 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
| 71 | + // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
| 72 | 72 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
| 73 | - // grab cats, tags, and terms, or forms or posts |
|
| 74 | - if ( isset($xml->{$item_type} ) ) { |
|
| 73 | + // grab cats, tags, and terms, or forms or posts |
|
| 74 | + if ( isset($xml->{$item_type} ) ) { |
|
| 75 | 75 | $function_name = 'import_xml_' . $item_type . 's'; |
| 76 | 76 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
| 77 | 77 | unset( $function_name, $xml->{$item_type} ); |
| 78 | - } |
|
| 79 | - } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
| 81 | + $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
| 82 | 82 | |
| 83 | - return $return; |
|
| 84 | - } |
|
| 83 | + return $return; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | public static function import_xml_terms( $terms, $imported ) { |
| 87 | - foreach ( $terms as $t ) { |
|
| 87 | + foreach ( $terms as $t ) { |
|
| 88 | 88 | if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
| 89 | - continue; |
|
| 89 | + continue; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $parent = self::get_term_parent_id( $t ); |
| 93 | 93 | |
| 94 | 94 | $term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array( |
| 95 | - 'slug' => (string) $t->term_slug, |
|
| 96 | - 'description' => (string) $t->term_description, |
|
| 95 | + 'slug' => (string) $t->term_slug, |
|
| 96 | + 'description' => (string) $t->term_description, |
|
| 97 | 97 | 'parent' => empty( $parent ) ? 0 : $parent, |
| 98 | - )); |
|
| 98 | + )); |
|
| 99 | 99 | |
| 100 | 100 | if ( $term && is_array( $term ) ) { |
| 101 | - $imported['imported']['terms']++; |
|
| 101 | + $imported['imported']['terms']++; |
|
| 102 | 102 | $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | unset( $term, $t ); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | return $imported; |
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * @since 2.0.8 |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | self::put_child_forms_first( $forms ); |
| 132 | 132 | |
| 133 | 133 | foreach ( $forms as $item ) { |
| 134 | - $form = self::fill_form( $item ); |
|
| 134 | + $form = self::fill_form( $item ); |
|
| 135 | 135 | |
| 136 | 136 | self::update_custom_style_setting_on_import( $form ); |
| 137 | 137 | |
| 138 | - $this_form = self::maybe_get_form( $form ); |
|
| 138 | + $this_form = self::maybe_get_form( $form ); |
|
| 139 | 139 | |
| 140 | 140 | $old_id = false; |
| 141 | 141 | $form_fields = false; |
@@ -147,35 +147,35 @@ discard block |
||
| 147 | 147 | $form_fields = self::get_form_fields( $form_id ); |
| 148 | 148 | } else { |
| 149 | 149 | $form_id = FrmForm::create( $form ); |
| 150 | - if ( $form_id ) { |
|
| 151 | - $imported['imported']['forms']++; |
|
| 152 | - // Keep track of whether this specific form was updated or not |
|
| 150 | + if ( $form_id ) { |
|
| 151 | + $imported['imported']['forms']++; |
|
| 152 | + // Keep track of whether this specific form was updated or not |
|
| 153 | 153 | $imported['form_status'][ $form_id ] = 'imported'; |
| 154 | 154 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 155 | - } |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported ); |
| 159 | 159 | |
| 160 | 160 | self::delete_removed_fields( $form_fields ); |
| 161 | 161 | |
| 162 | - // Update field ids/keys to new ones |
|
| 162 | + // Update field ids/keys to new ones |
|
| 163 | 163 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 164 | 164 | |
| 165 | 165 | $imported['forms'][ (int) $item->id ] = $form_id; |
| 166 | 166 | |
| 167 | - // Send pre 2.0 form options through function that creates actions |
|
| 168 | - self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
| 167 | + // Send pre 2.0 form options through function that creates actions |
|
| 168 | + self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
| 169 | 169 | |
| 170 | 170 | do_action( 'frm_after_import_form', $form_id, $form ); |
| 171 | 171 | |
| 172 | - unset($form, $item); |
|
| 172 | + unset($form, $item); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
| 176 | 176 | |
| 177 | 177 | return $imported; |
| 178 | - } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | private static function fill_form( $item ) { |
| 181 | 181 | $form = array( |
@@ -246,11 +246,11 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | - * Put child forms first so they will be imported before parents |
|
| 250 | - * |
|
| 251 | - * @since 2.0.16 |
|
| 252 | - * @param array $forms |
|
| 253 | - */ |
|
| 249 | + * Put child forms first so they will be imported before parents |
|
| 250 | + * |
|
| 251 | + * @since 2.0.16 |
|
| 252 | + * @param array $forms |
|
| 253 | + */ |
|
| 254 | 254 | private static function put_child_forms_first( &$forms ) { |
| 255 | 255 | $child_forms = array(); |
| 256 | 256 | $regular_forms = array(); |
@@ -269,13 +269,13 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | - * Keep track of all imported child forms |
|
| 273 | - * |
|
| 274 | - * @since 2.0.16 |
|
| 275 | - * @param int $form_id |
|
| 276 | - * @param int $parent_form_id |
|
| 277 | - * @param array $child_forms |
|
| 278 | - */ |
|
| 272 | + * Keep track of all imported child forms |
|
| 273 | + * |
|
| 274 | + * @since 2.0.16 |
|
| 275 | + * @param int $form_id |
|
| 276 | + * @param int $parent_form_id |
|
| 277 | + * @param array $child_forms |
|
| 278 | + */ |
|
| 279 | 279 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 280 | 280 | if ( $parent_form_id ) { |
| 281 | 281 | $child_forms[ $form_id ] = $parent_form_id; |
@@ -283,13 +283,13 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | - * Update the parent_form_id on imported child forms |
|
| 287 | - * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
| 288 | - * |
|
| 289 | - * @since 2.0.6 |
|
| 290 | - * @param array $imported_forms |
|
| 291 | - * @param array $child_forms |
|
| 292 | - */ |
|
| 286 | + * Update the parent_form_id on imported child forms |
|
| 287 | + * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
| 288 | + * |
|
| 289 | + * @since 2.0.6 |
|
| 290 | + * @param array $imported_forms |
|
| 291 | + * @param array $child_forms |
|
| 292 | + */ |
|
| 293 | 293 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 294 | 294 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 295 | 295 | |
@@ -303,11 +303,11 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
| 306 | - * Import all fields for a form |
|
| 307 | - * @since 2.0.13 |
|
| 308 | - * |
|
| 309 | - * TODO: Cut down on params |
|
| 310 | - */ |
|
| 306 | + * Import all fields for a form |
|
| 307 | + * @since 2.0.13 |
|
| 308 | + * |
|
| 309 | + * TODO: Cut down on params |
|
| 310 | + */ |
|
| 311 | 311 | private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) { |
| 312 | 312 | $in_section = 0; |
| 313 | 313 | |
@@ -400,12 +400,12 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
| 403 | - * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
| 404 | - * |
|
| 405 | - * @since 2.0.16 |
|
| 406 | - * @param array $f |
|
| 407 | - * @param array $imported |
|
| 408 | - */ |
|
| 403 | + * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
| 404 | + * |
|
| 405 | + * @since 2.0.16 |
|
| 406 | + * @param array $f |
|
| 407 | + * @param array $imported |
|
| 408 | + */ |
|
| 409 | 409 | private static function maybe_update_form_select( &$f, $imported ) { |
| 410 | 410 | if ( ! isset( $imported['forms'] ) ) { |
| 411 | 411 | return; |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
| 460 | - * Updates the custom style setting on import |
|
| 461 | - * Convert the post slug to an ID |
|
| 462 | - * |
|
| 463 | - * @since 2.0.19 |
|
| 464 | - * @param array $form |
|
| 465 | - * |
|
| 466 | - */ |
|
| 460 | + * Updates the custom style setting on import |
|
| 461 | + * Convert the post slug to an ID |
|
| 462 | + * |
|
| 463 | + * @since 2.0.19 |
|
| 464 | + * @param array $form |
|
| 465 | + * |
|
| 466 | + */ |
|
| 467 | 467 | private static function update_custom_style_setting_on_import( &$form ) { |
| 468 | 468 | if ( ! isset( $form['options']['custom_style'] ) ) { |
| 469 | 469 | return; |
@@ -517,16 +517,16 @@ discard block |
||
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | public static function import_xml_views( $views, $imported ) { |
| 520 | - $imported['posts'] = array(); |
|
| 521 | - $form_action_type = FrmFormActionsController::$action_post_type; |
|
| 520 | + $imported['posts'] = array(); |
|
| 521 | + $form_action_type = FrmFormActionsController::$action_post_type; |
|
| 522 | 522 | |
| 523 | - $post_types = array( |
|
| 524 | - 'frm_display' => 'views', |
|
| 525 | - $form_action_type => 'actions', |
|
| 526 | - 'frm_styles' => 'styles', |
|
| 527 | - ); |
|
| 523 | + $post_types = array( |
|
| 524 | + 'frm_display' => 'views', |
|
| 525 | + $form_action_type => 'actions', |
|
| 526 | + 'frm_styles' => 'styles', |
|
| 527 | + ); |
|
| 528 | 528 | |
| 529 | - foreach ( $views as $item ) { |
|
| 529 | + foreach ( $views as $item ) { |
|
| 530 | 530 | $post = array( |
| 531 | 531 | 'post_title' => (string) $item->title, |
| 532 | 532 | 'post_name' => (string) $item->post_name, |
@@ -545,52 +545,52 @@ discard block |
||
| 545 | 545 | 'post_date' => (string) $item->post_date, |
| 546 | 546 | 'post_date_gmt' => (string) $item->post_date_gmt, |
| 547 | 547 | 'ping_status' => (string) $item->ping_status, |
| 548 | - 'postmeta' => array(), |
|
| 549 | - 'tax_input' => array(), |
|
| 548 | + 'postmeta' => array(), |
|
| 549 | + 'tax_input' => array(), |
|
| 550 | 550 | ); |
| 551 | 551 | |
| 552 | - $old_id = $post['post_id']; |
|
| 553 | - self::populate_post($post, $item, $imported); |
|
| 552 | + $old_id = $post['post_id']; |
|
| 553 | + self::populate_post($post, $item, $imported); |
|
| 554 | 554 | |
| 555 | 555 | unset($item); |
| 556 | 556 | |
| 557 | 557 | $post_id = false; |
| 558 | - if ( $post['post_type'] == $form_action_type ) { |
|
| 559 | - $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
| 558 | + if ( $post['post_type'] == $form_action_type ) { |
|
| 559 | + $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
| 560 | 560 | if ( $action_control && is_object( $action_control ) ) { |
| 561 | 561 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
| 562 | 562 | } |
| 563 | - unset($action_control); |
|
| 564 | - } else if ( $post['post_type'] == 'frm_styles' ) { |
|
| 565 | - // Properly encode post content before inserting the post |
|
| 566 | - $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
| 563 | + unset($action_control); |
|
| 564 | + } else if ( $post['post_type'] == 'frm_styles' ) { |
|
| 565 | + // Properly encode post content before inserting the post |
|
| 566 | + $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
| 567 | 567 | $custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : ''; |
| 568 | - $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
| 568 | + $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
| 569 | 569 | |
| 570 | - // Create/update post now |
|
| 571 | - $post_id = wp_insert_post( $post ); |
|
| 570 | + // Create/update post now |
|
| 571 | + $post_id = wp_insert_post( $post ); |
|
| 572 | 572 | self::maybe_update_custom_css( $custom_css ); |
| 573 | - } else { |
|
| 574 | - // Create/update post now |
|
| 575 | - $post_id = wp_insert_post( $post ); |
|
| 576 | - } |
|
| 573 | + } else { |
|
| 574 | + // Create/update post now |
|
| 575 | + $post_id = wp_insert_post( $post ); |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - if ( ! is_numeric($post_id) ) { |
|
| 579 | - continue; |
|
| 580 | - } |
|
| 578 | + if ( ! is_numeric($post_id) ) { |
|
| 579 | + continue; |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - self::update_postmeta($post, $post_id); |
|
| 582 | + self::update_postmeta($post, $post_id); |
|
| 583 | 583 | |
| 584 | - $this_type = 'posts'; |
|
| 584 | + $this_type = 'posts'; |
|
| 585 | 585 | if ( isset( $post_types[ $post['post_type'] ] ) ) { |
| 586 | 586 | $this_type = $post_types[ $post['post_type'] ]; |
| 587 | - } |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
| 590 | - $imported['updated'][ $this_type ]++; |
|
| 591 | - } else { |
|
| 592 | - $imported['imported'][ $this_type ]++; |
|
| 593 | - } |
|
| 589 | + if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
| 590 | + $imported['updated'][ $this_type ]++; |
|
| 591 | + } else { |
|
| 592 | + $imported['imported'][ $this_type ]++; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | 595 | $imported['posts'][ (int) $old_id ] = $post_id; |
| 596 | 596 | |
@@ -602,16 +602,16 @@ discard block |
||
| 602 | 602 | self::maybe_update_stylesheet( $imported ); |
| 603 | 603 | |
| 604 | 604 | return $imported; |
| 605 | - } |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | - private static function populate_post( &$post, $item, $imported ) { |
|
| 607 | + private static function populate_post( &$post, $item, $imported ) { |
|
| 608 | 608 | if ( isset($item->attachment_url) ) { |
| 609 | 609 | $post['attachment_url'] = (string) $item->attachment_url; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
| 613 | - // update to new form id |
|
| 614 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 613 | + // update to new form id |
|
| 614 | + $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | // Don't allow default styles to take over a site's default style |
@@ -620,144 +620,144 @@ discard block |
||
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | foreach ( $item->postmeta as $meta ) { |
| 623 | - self::populate_postmeta($post, $meta, $imported); |
|
| 623 | + self::populate_postmeta($post, $meta, $imported); |
|
| 624 | 624 | unset($meta); |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - self::populate_taxonomies($post, $item); |
|
| 627 | + self::populate_taxonomies($post, $item); |
|
| 628 | 628 | |
| 629 | - self::maybe_editing_post($post); |
|
| 630 | - } |
|
| 629 | + self::maybe_editing_post($post); |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | - private static function populate_postmeta( &$post, $meta, $imported ) { |
|
| 633 | - global $frm_duplicate_ids; |
|
| 632 | + private static function populate_postmeta( &$post, $meta, $imported ) { |
|
| 633 | + global $frm_duplicate_ids; |
|
| 634 | 634 | |
| 635 | - $m = array( |
|
| 635 | + $m = array( |
|
| 636 | 636 | 'key' => (string) $meta->meta_key, |
| 637 | 637 | 'value' => (string) $meta->meta_value, |
| 638 | 638 | ); |
| 639 | 639 | |
| 640 | 640 | //switch old form and field ids to new ones |
| 641 | 641 | if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
| 642 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 642 | + $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 643 | 643 | } else { |
| 644 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 644 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 645 | 645 | |
| 646 | - if ( ! empty($frm_duplicate_ids) ) { |
|
| 646 | + if ( ! empty($frm_duplicate_ids) ) { |
|
| 647 | 647 | |
| 648 | - if ( $m['key'] == 'frm_dyncontent' ) { |
|
| 649 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
| 650 | - } else if ( $m['key'] == 'frm_options' ) { |
|
| 648 | + if ( $m['key'] == 'frm_dyncontent' ) { |
|
| 649 | + $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
| 650 | + } else if ( $m['key'] == 'frm_options' ) { |
|
| 651 | 651 | |
| 652 | 652 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 653 | 653 | if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
| 654 | 654 | $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
| 655 | - } |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - $check_dup_array = array(); |
|
| 659 | - if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
| 660 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 661 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 662 | - } else if ( is_array( $m['value']['order_by'] ) ) { |
|
| 663 | - $check_dup_array[] = 'order_by'; |
|
| 664 | - } |
|
| 665 | - } |
|
| 666 | - |
|
| 667 | - if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
| 668 | - $check_dup_array[] = 'where'; |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - foreach ( $check_dup_array as $check_k ) { |
|
| 655 | + } |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + $check_dup_array = array(); |
|
| 659 | + if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
| 660 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 661 | + $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 662 | + } else if ( is_array( $m['value']['order_by'] ) ) { |
|
| 663 | + $check_dup_array[] = 'order_by'; |
|
| 664 | + } |
|
| 665 | + } |
|
| 666 | + |
|
| 667 | + if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
| 668 | + $check_dup_array[] = 'where'; |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + foreach ( $check_dup_array as $check_k ) { |
|
| 672 | 672 | foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
| 673 | 673 | if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
| 674 | 674 | $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
| 675 | - } |
|
| 676 | - unset($mk, $mv); |
|
| 677 | - } |
|
| 678 | - } |
|
| 679 | - } |
|
| 680 | - } |
|
| 675 | + } |
|
| 676 | + unset($mk, $mv); |
|
| 677 | + } |
|
| 678 | + } |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | if ( ! is_array($m['value']) ) { |
| 684 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 684 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
| 688 | - } |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * Add terms to post |
|
| 692 | - * @param array $post by reference |
|
| 693 | - * @param object $item The XML object data |
|
| 694 | - */ |
|
| 695 | - private static function populate_taxonomies( &$post, $item ) { |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * Add terms to post |
|
| 692 | + * @param array $post by reference |
|
| 693 | + * @param object $item The XML object data |
|
| 694 | + */ |
|
| 695 | + private static function populate_taxonomies( &$post, $item ) { |
|
| 696 | 696 | foreach ( $item->category as $c ) { |
| 697 | 697 | $att = $c->attributes(); |
| 698 | 698 | if ( ! isset( $att['nicename'] ) ) { |
| 699 | - continue; |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - $taxonomy = (string) $att['domain']; |
|
| 703 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
| 704 | - $name = (string) $att['nicename']; |
|
| 705 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
| 706 | - if ( $h_term ) { |
|
| 707 | - $name = $h_term->term_id; |
|
| 708 | - } |
|
| 709 | - unset($h_term); |
|
| 710 | - } else { |
|
| 711 | - $name = (string) $c; |
|
| 712 | - } |
|
| 699 | + continue; |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + $taxonomy = (string) $att['domain']; |
|
| 703 | + if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
| 704 | + $name = (string) $att['nicename']; |
|
| 705 | + $h_term = get_term_by('slug', $name, $taxonomy); |
|
| 706 | + if ( $h_term ) { |
|
| 707 | + $name = $h_term->term_id; |
|
| 708 | + } |
|
| 709 | + unset($h_term); |
|
| 710 | + } else { |
|
| 711 | + $name = (string) $c; |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | 714 | if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
| 715 | 715 | $post['tax_input'][ $taxonomy ] = array(); |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | $post['tax_input'][ $taxonomy ][] = $name; |
| 719 | - unset($name); |
|
| 719 | + unset($name); |
|
| 720 | 720 | } |
| 721 | - } |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | - /** |
|
| 724 | - * Edit post if the key and created time match |
|
| 725 | - */ |
|
| 726 | - private static function maybe_editing_post( &$post ) { |
|
| 723 | + /** |
|
| 724 | + * Edit post if the key and created time match |
|
| 725 | + */ |
|
| 726 | + private static function maybe_editing_post( &$post ) { |
|
| 727 | 727 | $match_by = array( |
| 728 | - 'post_type' => $post['post_type'], |
|
| 729 | - 'name' => $post['post_name'], |
|
| 730 | - 'post_status' => $post['post_status'], |
|
| 731 | - 'posts_per_page' => 1, |
|
| 728 | + 'post_type' => $post['post_type'], |
|
| 729 | + 'name' => $post['post_name'], |
|
| 730 | + 'post_status' => $post['post_status'], |
|
| 731 | + 'posts_per_page' => 1, |
|
| 732 | 732 | ); |
| 733 | 733 | |
| 734 | 734 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
| 735 | - $match_by['include'] = $post['post_id']; |
|
| 736 | - unset($match_by['name']); |
|
| 735 | + $match_by['include'] = $post['post_id']; |
|
| 736 | + unset($match_by['name']); |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | $editing = get_posts($match_by); |
| 740 | 740 | |
| 741 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
| 742 | - // set the id of the post to edit |
|
| 743 | - $post['ID'] = current($editing)->ID; |
|
| 744 | - } |
|
| 745 | - } |
|
| 741 | + if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
| 742 | + // set the id of the post to edit |
|
| 743 | + $post['ID'] = current($editing)->ID; |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | - private static function update_postmeta( &$post, $post_id ) { |
|
| 748 | - foreach ( $post['postmeta'] as $k => $v ) { |
|
| 749 | - if ( '_edit_last' == $k ) { |
|
| 750 | - $v = FrmAppHelper::get_user_id_param($v); |
|
| 751 | - } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
| 752 | - //change the attachment ID |
|
| 753 | - $v = FrmProXMLHelper::get_file_id($v); |
|
| 754 | - } |
|
| 747 | + private static function update_postmeta( &$post, $post_id ) { |
|
| 748 | + foreach ( $post['postmeta'] as $k => $v ) { |
|
| 749 | + if ( '_edit_last' == $k ) { |
|
| 750 | + $v = FrmAppHelper::get_user_id_param($v); |
|
| 751 | + } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
| 752 | + //change the attachment ID |
|
| 753 | + $v = FrmProXMLHelper::get_file_id($v); |
|
| 754 | + } |
|
| 755 | 755 | |
| 756 | - update_post_meta($post_id, $k, $v); |
|
| 756 | + update_post_meta($post_id, $k, $v); |
|
| 757 | 757 | |
| 758 | - unset($k, $v); |
|
| 759 | - } |
|
| 760 | - } |
|
| 758 | + unset($k, $v); |
|
| 759 | + } |
|
| 760 | + } |
|
| 761 | 761 | |
| 762 | 762 | /** |
| 763 | 763 | * If a template includes custom css, let's include it. |
@@ -790,72 +790,72 @@ discard block |
||
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | - /** |
|
| 794 | - * @param string $message |
|
| 795 | - */ |
|
| 793 | + /** |
|
| 794 | + * @param string $message |
|
| 795 | + */ |
|
| 796 | 796 | public static function parse_message( $result, &$message, &$errors ) { |
| 797 | - if ( is_wp_error($result) ) { |
|
| 798 | - $errors[] = $result->get_error_message(); |
|
| 799 | - } else if ( ! $result ) { |
|
| 800 | - return; |
|
| 801 | - } |
|
| 802 | - |
|
| 803 | - if ( ! is_array($result) ) { |
|
| 804 | - $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) ); |
|
| 805 | - return; |
|
| 806 | - } |
|
| 807 | - |
|
| 808 | - $t_strings = array( |
|
| 809 | - 'imported' => __( 'Imported', 'formidable' ), |
|
| 810 | - 'updated' => __( 'Updated', 'formidable' ), |
|
| 811 | - ); |
|
| 812 | - |
|
| 813 | - $message = '<ul>'; |
|
| 814 | - foreach ( $result as $type => $results ) { |
|
| 797 | + if ( is_wp_error($result) ) { |
|
| 798 | + $errors[] = $result->get_error_message(); |
|
| 799 | + } else if ( ! $result ) { |
|
| 800 | + return; |
|
| 801 | + } |
|
| 802 | + |
|
| 803 | + if ( ! is_array($result) ) { |
|
| 804 | + $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) ); |
|
| 805 | + return; |
|
| 806 | + } |
|
| 807 | + |
|
| 808 | + $t_strings = array( |
|
| 809 | + 'imported' => __( 'Imported', 'formidable' ), |
|
| 810 | + 'updated' => __( 'Updated', 'formidable' ), |
|
| 811 | + ); |
|
| 812 | + |
|
| 813 | + $message = '<ul>'; |
|
| 814 | + foreach ( $result as $type => $results ) { |
|
| 815 | 815 | if ( ! isset( $t_strings[ $type ] ) ) { |
| 816 | - // only print imported and updated |
|
| 817 | - continue; |
|
| 818 | - } |
|
| 816 | + // only print imported and updated |
|
| 817 | + continue; |
|
| 818 | + } |
|
| 819 | 819 | |
| 820 | - $s_message = array(); |
|
| 821 | - foreach ( $results as $k => $m ) { |
|
| 822 | - self::item_count_message($m, $k, $s_message); |
|
| 823 | - unset($k, $m); |
|
| 824 | - } |
|
| 820 | + $s_message = array(); |
|
| 821 | + foreach ( $results as $k => $m ) { |
|
| 822 | + self::item_count_message($m, $k, $s_message); |
|
| 823 | + unset($k, $m); |
|
| 824 | + } |
|
| 825 | 825 | |
| 826 | - if ( ! empty($s_message) ) { |
|
| 826 | + if ( ! empty($s_message) ) { |
|
| 827 | 827 | $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
| 828 | - $message .= implode(', ', $s_message); |
|
| 829 | - $message .= '</li>'; |
|
| 830 | - } |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - if ( $message == '<ul>' ) { |
|
| 834 | - $message = ''; |
|
| 835 | - $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
| 836 | - } else { |
|
| 837 | - $message .= '</ul>'; |
|
| 838 | - } |
|
| 839 | - } |
|
| 828 | + $message .= implode(', ', $s_message); |
|
| 829 | + $message .= '</li>'; |
|
| 830 | + } |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + if ( $message == '<ul>' ) { |
|
| 834 | + $message = ''; |
|
| 835 | + $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
| 836 | + } else { |
|
| 837 | + $message .= '</ul>'; |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | 840 | |
| 841 | 841 | public static function item_count_message( $m, $type, &$s_message ) { |
| 842 | - if ( ! $m ) { |
|
| 843 | - return; |
|
| 844 | - } |
|
| 845 | - |
|
| 846 | - $strings = array( |
|
| 847 | - 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
| 848 | - 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
| 849 | - 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
| 850 | - 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
| 851 | - 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
| 852 | - 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
| 853 | - 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
| 854 | - 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
| 855 | - ); |
|
| 842 | + if ( ! $m ) { |
|
| 843 | + return; |
|
| 844 | + } |
|
| 845 | + |
|
| 846 | + $strings = array( |
|
| 847 | + 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
| 848 | + 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
| 849 | + 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
| 850 | + 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
| 851 | + 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
| 852 | + 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
| 853 | + 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
| 854 | + 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
| 855 | + ); |
|
| 856 | 856 | |
| 857 | 857 | $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
| 858 | - } |
|
| 858 | + } |
|
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | 861 | * Prepare the form options for export |
@@ -886,16 +886,16 @@ discard block |
||
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | public static function cdata( $str ) { |
| 889 | - $str = maybe_unserialize($str); |
|
| 890 | - if ( is_array($str) ) { |
|
| 891 | - $str = json_encode($str); |
|
| 889 | + $str = maybe_unserialize($str); |
|
| 890 | + if ( is_array($str) ) { |
|
| 891 | + $str = json_encode($str); |
|
| 892 | 892 | } else if ( seems_utf8( $str ) == false ) { |
| 893 | 893 | $str = utf8_encode( $str ); |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | - if ( is_numeric($str) ) { |
|
| 897 | - return $str; |
|
| 898 | - } |
|
| 896 | + if ( is_numeric($str) ) { |
|
| 897 | + return $str; |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | 900 | self::remove_invalid_characters_from_xml( $str ); |
| 901 | 901 | |
@@ -916,54 +916,54 @@ discard block |
||
| 916 | 916 | $str = str_replace( '\x1F', '', $str ); |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
| 920 | - // Get post type |
|
| 921 | - $post_type = FrmFormActionsController::$action_post_type; |
|
| 922 | - |
|
| 923 | - // Set up imported index, if not set up yet |
|
| 924 | - if ( ! isset( $imported['imported']['actions'] ) ) { |
|
| 925 | - $imported['imported']['actions'] = 0; |
|
| 926 | - } |
|
| 927 | - |
|
| 928 | - // Migrate post settings to action |
|
| 929 | - self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 930 | - |
|
| 931 | - // Migrate email settings to action |
|
| 932 | - self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 933 | - } |
|
| 934 | - |
|
| 935 | - /** |
|
| 936 | - * Migrate post settings to form action |
|
| 937 | - * |
|
| 938 | - * @param string $post_type |
|
| 939 | - */ |
|
| 940 | - private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 941 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
| 942 | - return; |
|
| 943 | - } |
|
| 944 | - |
|
| 945 | - $new_action = array( |
|
| 946 | - 'post_type' => $post_type, |
|
| 947 | - 'post_excerpt' => 'wppost', |
|
| 919 | + public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
| 920 | + // Get post type |
|
| 921 | + $post_type = FrmFormActionsController::$action_post_type; |
|
| 922 | + |
|
| 923 | + // Set up imported index, if not set up yet |
|
| 924 | + if ( ! isset( $imported['imported']['actions'] ) ) { |
|
| 925 | + $imported['imported']['actions'] = 0; |
|
| 926 | + } |
|
| 927 | + |
|
| 928 | + // Migrate post settings to action |
|
| 929 | + self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 930 | + |
|
| 931 | + // Migrate email settings to action |
|
| 932 | + self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 933 | + } |
|
| 934 | + |
|
| 935 | + /** |
|
| 936 | + * Migrate post settings to form action |
|
| 937 | + * |
|
| 938 | + * @param string $post_type |
|
| 939 | + */ |
|
| 940 | + private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 941 | + if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
| 942 | + return; |
|
| 943 | + } |
|
| 944 | + |
|
| 945 | + $new_action = array( |
|
| 946 | + 'post_type' => $post_type, |
|
| 947 | + 'post_excerpt' => 'wppost', |
|
| 948 | 948 | 'post_title' => __( 'Create Posts', 'formidable' ), |
| 949 | - 'menu_order' => $form_id, |
|
| 950 | - 'post_status' => 'publish', |
|
| 951 | - 'post_content' => array(), |
|
| 949 | + 'menu_order' => $form_id, |
|
| 950 | + 'post_status' => 'publish', |
|
| 951 | + 'post_content' => array(), |
|
| 952 | 952 | 'post_name' => $form_id . '_wppost_1', |
| 953 | - ); |
|
| 953 | + ); |
|
| 954 | 954 | |
| 955 | 955 | $post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' ); |
| 956 | 956 | |
| 957 | - foreach ( $post_settings as $post_setting ) { |
|
| 957 | + foreach ( $post_settings as $post_setting ) { |
|
| 958 | 958 | if ( isset( $form_options[ $post_setting ] ) ) { |
| 959 | 959 | $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
| 960 | - } |
|
| 961 | - unset($post_setting); |
|
| 962 | - } |
|
| 960 | + } |
|
| 961 | + unset($post_setting); |
|
| 962 | + } |
|
| 963 | 963 | |
| 964 | 964 | $new_action['event'] = array( 'create', 'update' ); |
| 965 | 965 | |
| 966 | - if ( $switch ) { |
|
| 966 | + if ( $switch ) { |
|
| 967 | 967 | // Fields with string or int saved |
| 968 | 968 | $basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' ); |
| 969 | 969 | |
@@ -971,22 +971,22 @@ discard block |
||
| 971 | 971 | $array_fields = array( 'post_category', 'post_custom_fields' ); |
| 972 | 972 | |
| 973 | 973 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
| 974 | - } |
|
| 975 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
| 974 | + } |
|
| 975 | + $new_action['post_content'] = json_encode($new_action['post_content']); |
|
| 976 | 976 | |
| 977 | - $exists = get_posts( array( |
|
| 978 | - 'name' => $new_action['post_name'], |
|
| 979 | - 'post_type' => $new_action['post_type'], |
|
| 980 | - 'post_status' => $new_action['post_status'], |
|
| 981 | - 'numberposts' => 1, |
|
| 982 | - ) ); |
|
| 977 | + $exists = get_posts( array( |
|
| 978 | + 'name' => $new_action['post_name'], |
|
| 979 | + 'post_type' => $new_action['post_type'], |
|
| 980 | + 'post_status' => $new_action['post_status'], |
|
| 981 | + 'numberposts' => 1, |
|
| 982 | + ) ); |
|
| 983 | 983 | |
| 984 | - if ( ! $exists ) { |
|
| 984 | + if ( ! $exists ) { |
|
| 985 | 985 | // this isn't an email, but we need to use a class that will always be included |
| 986 | 986 | FrmDb::save_json_post( $new_action ); |
| 987 | - $imported['imported']['actions']++; |
|
| 988 | - } |
|
| 989 | - } |
|
| 987 | + $imported['imported']['actions']++; |
|
| 988 | + } |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | 991 | /** |
| 992 | 992 | * Switch old field IDs for new field IDs in emails and post |
@@ -999,88 +999,88 @@ discard block |
||
| 999 | 999 | * @return string $post_content - new field IDs |
| 1000 | 1000 | */ |
| 1001 | 1001 | private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) { |
| 1002 | - global $frm_duplicate_ids; |
|
| 1002 | + global $frm_duplicate_ids; |
|
| 1003 | 1003 | |
| 1004 | - // If there aren't IDs that were switched, end now |
|
| 1005 | - if ( ! $frm_duplicate_ids ) { |
|
| 1006 | - return; |
|
| 1007 | - } |
|
| 1004 | + // If there aren't IDs that were switched, end now |
|
| 1005 | + if ( ! $frm_duplicate_ids ) { |
|
| 1006 | + return; |
|
| 1007 | + } |
|
| 1008 | 1008 | |
| 1009 | - // Get old IDs |
|
| 1010 | - $old = array_keys( $frm_duplicate_ids ); |
|
| 1009 | + // Get old IDs |
|
| 1010 | + $old = array_keys( $frm_duplicate_ids ); |
|
| 1011 | 1011 | |
| 1012 | - // Get new IDs |
|
| 1013 | - $new = array_values( $frm_duplicate_ids ); |
|
| 1012 | + // Get new IDs |
|
| 1013 | + $new = array_values( $frm_duplicate_ids ); |
|
| 1014 | 1014 | |
| 1015 | - // Do a str_replace with each item to set the new IDs |
|
| 1016 | - foreach ( $post_content as $key => $setting ) { |
|
| 1017 | - if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
| 1018 | - // Replace old IDs with new IDs |
|
| 1015 | + // Do a str_replace with each item to set the new IDs |
|
| 1016 | + foreach ( $post_content as $key => $setting ) { |
|
| 1017 | + if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
| 1018 | + // Replace old IDs with new IDs |
|
| 1019 | 1019 | $post_content[ $key ] = str_replace( $old, $new, $setting ); |
| 1020 | - } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
| 1021 | - foreach ( $setting as $k => $val ) { |
|
| 1022 | - // Replace old IDs with new IDs |
|
| 1020 | + } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
| 1021 | + foreach ( $setting as $k => $val ) { |
|
| 1022 | + // Replace old IDs with new IDs |
|
| 1023 | 1023 | $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
| 1024 | - } |
|
| 1025 | - } |
|
| 1026 | - unset( $key, $setting ); |
|
| 1027 | - } |
|
| 1028 | - return $post_content; |
|
| 1029 | - } |
|
| 1030 | - |
|
| 1031 | - private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1032 | - // No old notifications or autoresponders to carry over |
|
| 1024 | + } |
|
| 1025 | + } |
|
| 1026 | + unset( $key, $setting ); |
|
| 1027 | + } |
|
| 1028 | + return $post_content; |
|
| 1029 | + } |
|
| 1030 | + |
|
| 1031 | + private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1032 | + // No old notifications or autoresponders to carry over |
|
| 1033 | 1033 | if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) { |
| 1034 | - return; |
|
| 1035 | - } |
|
| 1034 | + return; |
|
| 1035 | + } |
|
| 1036 | 1036 | |
| 1037 | - // Initialize notifications array |
|
| 1038 | - $notifications = array(); |
|
| 1037 | + // Initialize notifications array |
|
| 1038 | + $notifications = array(); |
|
| 1039 | 1039 | |
| 1040 | - // Migrate regular notifications |
|
| 1041 | - self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
| 1040 | + // Migrate regular notifications |
|
| 1041 | + self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
| 1042 | 1042 | |
| 1043 | - // Migrate autoresponders |
|
| 1044 | - self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
| 1043 | + // Migrate autoresponders |
|
| 1044 | + self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
| 1045 | 1045 | |
| 1046 | - if ( empty( $notifications ) ) { |
|
| 1047 | - return; |
|
| 1048 | - } |
|
| 1046 | + if ( empty( $notifications ) ) { |
|
| 1047 | + return; |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | - foreach ( $notifications as $new_notification ) { |
|
| 1051 | - $new_notification['post_type'] = $post_type; |
|
| 1052 | - $new_notification['post_excerpt'] = 'email'; |
|
| 1050 | + foreach ( $notifications as $new_notification ) { |
|
| 1051 | + $new_notification['post_type'] = $post_type; |
|
| 1052 | + $new_notification['post_excerpt'] = 'email'; |
|
| 1053 | 1053 | $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
| 1054 | - $new_notification['menu_order'] = $form_id; |
|
| 1055 | - $new_notification['post_status'] = 'publish'; |
|
| 1054 | + $new_notification['menu_order'] = $form_id; |
|
| 1055 | + $new_notification['post_status'] = 'publish'; |
|
| 1056 | 1056 | |
| 1057 | - // Switch field IDs and keys, if needed |
|
| 1058 | - if ( $switch ) { |
|
| 1057 | + // Switch field IDs and keys, if needed |
|
| 1058 | + if ( $switch ) { |
|
| 1059 | 1059 | |
| 1060 | 1060 | // Switch field IDs in email conditional logic |
| 1061 | 1061 | self::switch_email_contition_field_ids( $new_notification['post_content'] ); |
| 1062 | 1062 | |
| 1063 | 1063 | // Switch all other field IDs in email |
| 1064 | - $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
| 1065 | - } |
|
| 1066 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1067 | - |
|
| 1068 | - $exists = get_posts( array( |
|
| 1069 | - 'name' => $new_notification['post_name'], |
|
| 1070 | - 'post_type' => $new_notification['post_type'], |
|
| 1071 | - 'post_status' => $new_notification['post_status'], |
|
| 1072 | - 'numberposts' => 1, |
|
| 1073 | - ) ); |
|
| 1074 | - |
|
| 1075 | - if ( empty($exists) ) { |
|
| 1064 | + $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
| 1065 | + } |
|
| 1066 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1067 | + |
|
| 1068 | + $exists = get_posts( array( |
|
| 1069 | + 'name' => $new_notification['post_name'], |
|
| 1070 | + 'post_type' => $new_notification['post_type'], |
|
| 1071 | + 'post_status' => $new_notification['post_status'], |
|
| 1072 | + 'numberposts' => 1, |
|
| 1073 | + ) ); |
|
| 1074 | + |
|
| 1075 | + if ( empty($exists) ) { |
|
| 1076 | 1076 | FrmDb::save_json_post( $new_notification ); |
| 1077 | - $imported['imported']['actions']++; |
|
| 1078 | - } |
|
| 1079 | - unset($new_notification); |
|
| 1080 | - } |
|
| 1077 | + $imported['imported']['actions']++; |
|
| 1078 | + } |
|
| 1079 | + unset($new_notification); |
|
| 1080 | + } |
|
| 1081 | 1081 | |
| 1082 | 1082 | self::remove_deprecated_notification_settings( $form_id, $form_options ); |
| 1083 | - } |
|
| 1083 | + } |
|
| 1084 | 1084 | |
| 1085 | 1085 | /** |
| 1086 | 1086 | * Remove deprecated notification settings after migration |
@@ -1100,17 +1100,17 @@ discard block |
||
| 1100 | 1100 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1104 | - if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
| 1105 | - // add old settings into notification array |
|
| 1103 | + private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1104 | + if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
| 1105 | + // add old settings into notification array |
|
| 1106 | 1106 | $form_options['notification'] = array( 0 => $form_options ); |
| 1107 | - } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
| 1108 | - // make sure it's in the correct format |
|
| 1107 | + } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
| 1108 | + // make sure it's in the correct format |
|
| 1109 | 1109 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
| 1110 | - } |
|
| 1110 | + } |
|
| 1111 | 1111 | |
| 1112 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
| 1113 | - foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
| 1112 | + if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
| 1113 | + foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
| 1114 | 1114 | |
| 1115 | 1115 | $atts = array( |
| 1116 | 1116 | 'email_to' => '', |
@@ -1121,119 +1121,119 @@ discard block |
||
| 1121 | 1121 | 'email_key' => $email_key, |
| 1122 | 1122 | ); |
| 1123 | 1123 | |
| 1124 | - // Format the email data |
|
| 1125 | - self::format_email_data( $atts, $notification ); |
|
| 1124 | + // Format the email data |
|
| 1125 | + self::format_email_data( $atts, $notification ); |
|
| 1126 | 1126 | |
| 1127 | 1127 | if ( isset( $notification['twilio'] ) && $notification['twilio'] ) { |
| 1128 | 1128 | do_action( 'frm_create_twilio_action', $atts, $notification ); |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | - // Setup the new notification |
|
| 1132 | - $new_notification = array(); |
|
| 1133 | - self::setup_new_notification( $new_notification, $notification, $atts ); |
|
| 1131 | + // Setup the new notification |
|
| 1132 | + $new_notification = array(); |
|
| 1133 | + self::setup_new_notification( $new_notification, $notification, $atts ); |
|
| 1134 | 1134 | |
| 1135 | - $notifications[] = $new_notification; |
|
| 1136 | - } |
|
| 1137 | - } |
|
| 1138 | - } |
|
| 1135 | + $notifications[] = $new_notification; |
|
| 1136 | + } |
|
| 1137 | + } |
|
| 1138 | + } |
|
| 1139 | 1139 | |
| 1140 | - private static function format_email_data( &$atts, $notification ) { |
|
| 1141 | - // Format email_to |
|
| 1142 | - self::format_email_to_data( $atts, $notification ); |
|
| 1140 | + private static function format_email_data( &$atts, $notification ) { |
|
| 1141 | + // Format email_to |
|
| 1142 | + self::format_email_to_data( $atts, $notification ); |
|
| 1143 | 1143 | |
| 1144 | - // Format the reply to email and name |
|
| 1144 | + // Format the reply to email and name |
|
| 1145 | 1145 | $reply_fields = array( |
| 1146 | 1146 | 'reply_to' => '', |
| 1147 | 1147 | 'reply_to_name' => '', |
| 1148 | 1148 | ); |
| 1149 | - foreach ( $reply_fields as $f => $val ) { |
|
| 1149 | + foreach ( $reply_fields as $f => $val ) { |
|
| 1150 | 1150 | if ( isset( $notification[ $f ] ) ) { |
| 1151 | 1151 | $atts[ $f ] = $notification[ $f ]; |
| 1152 | 1152 | if ( 'custom' == $notification[ $f ] ) { |
| 1153 | 1153 | $atts[ $f ] = $notification[ 'cust_' . $f ]; |
| 1154 | 1154 | } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
| 1155 | 1155 | $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
| 1156 | - } |
|
| 1157 | - } |
|
| 1158 | - unset( $f, $val ); |
|
| 1159 | - } |
|
| 1156 | + } |
|
| 1157 | + } |
|
| 1158 | + unset( $f, $val ); |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | - // Format event |
|
| 1161 | + // Format event |
|
| 1162 | 1162 | $atts['event'] = array( 'create' ); |
| 1163 | - if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
| 1164 | - $atts['event'][] = 'update'; |
|
| 1165 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
| 1163 | + if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
| 1164 | + $atts['event'][] = 'update'; |
|
| 1165 | + } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
| 1166 | 1166 | $atts['event'] = array( 'update' ); |
| 1167 | - } |
|
| 1168 | - } |
|
| 1167 | + } |
|
| 1168 | + } |
|
| 1169 | 1169 | |
| 1170 | - private static function format_email_to_data( &$atts, $notification ) { |
|
| 1171 | - if ( isset( $notification['email_to'] ) ) { |
|
| 1170 | + private static function format_email_to_data( &$atts, $notification ) { |
|
| 1171 | + if ( isset( $notification['email_to'] ) ) { |
|
| 1172 | 1172 | $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] ); |
| 1173 | - } else { |
|
| 1174 | - $atts['email_to'] = array(); |
|
| 1175 | - } |
|
| 1173 | + } else { |
|
| 1174 | + $atts['email_to'] = array(); |
|
| 1175 | + } |
|
| 1176 | 1176 | |
| 1177 | - if ( isset( $notification['also_email_to'] ) ) { |
|
| 1178 | - $email_fields = (array) $notification['also_email_to']; |
|
| 1179 | - $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
| 1180 | - unset( $email_fields ); |
|
| 1181 | - } |
|
| 1177 | + if ( isset( $notification['also_email_to'] ) ) { |
|
| 1178 | + $email_fields = (array) $notification['also_email_to']; |
|
| 1179 | + $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
| 1180 | + unset( $email_fields ); |
|
| 1181 | + } |
|
| 1182 | 1182 | |
| 1183 | - foreach ( $atts['email_to'] as $key => $email_field ) { |
|
| 1183 | + foreach ( $atts['email_to'] as $key => $email_field ) { |
|
| 1184 | 1184 | |
| 1185 | - if ( is_numeric( $email_field ) ) { |
|
| 1185 | + if ( is_numeric( $email_field ) ) { |
|
| 1186 | 1186 | $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
| 1187 | - } |
|
| 1187 | + } |
|
| 1188 | 1188 | |
| 1189 | - if ( strpos( $email_field, '|') ) { |
|
| 1190 | - $email_opt = explode( '|', $email_field ); |
|
| 1191 | - if ( isset( $email_opt[0] ) ) { |
|
| 1189 | + if ( strpos( $email_field, '|') ) { |
|
| 1190 | + $email_opt = explode( '|', $email_field ); |
|
| 1191 | + if ( isset( $email_opt[0] ) ) { |
|
| 1192 | 1192 | $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
| 1193 | - } |
|
| 1194 | - unset( $email_opt ); |
|
| 1195 | - } |
|
| 1196 | - } |
|
| 1197 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
| 1198 | - } |
|
| 1199 | - |
|
| 1200 | - private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
| 1201 | - // Set up new notification |
|
| 1202 | - $new_notification = array( |
|
| 1203 | - 'post_content' => array( |
|
| 1204 | - 'email_to' => $atts['email_to'], |
|
| 1205 | - 'event' => $atts['event'], |
|
| 1206 | - ), |
|
| 1193 | + } |
|
| 1194 | + unset( $email_opt ); |
|
| 1195 | + } |
|
| 1196 | + } |
|
| 1197 | + $atts['email_to'] = implode(', ', $atts['email_to']); |
|
| 1198 | + } |
|
| 1199 | + |
|
| 1200 | + private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
| 1201 | + // Set up new notification |
|
| 1202 | + $new_notification = array( |
|
| 1203 | + 'post_content' => array( |
|
| 1204 | + 'email_to' => $atts['email_to'], |
|
| 1205 | + 'event' => $atts['event'], |
|
| 1206 | + ), |
|
| 1207 | 1207 | 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
| 1208 | - ); |
|
| 1208 | + ); |
|
| 1209 | 1209 | |
| 1210 | - // Add more fields to the new notification |
|
| 1211 | - $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
| 1212 | - foreach ( $add_fields as $add_field ) { |
|
| 1210 | + // Add more fields to the new notification |
|
| 1211 | + $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
| 1212 | + foreach ( $add_fields as $add_field ) { |
|
| 1213 | 1213 | if ( isset( $notification[ $add_field ] ) ) { |
| 1214 | 1214 | $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
| 1215 | - } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
| 1215 | + } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
| 1216 | 1216 | $new_notification['post_content'][ $add_field ] = 0; |
| 1217 | - } else { |
|
| 1217 | + } else { |
|
| 1218 | 1218 | $new_notification['post_content'][ $add_field ] = ''; |
| 1219 | - } |
|
| 1220 | - unset( $add_field ); |
|
| 1221 | - } |
|
| 1219 | + } |
|
| 1220 | + unset( $add_field ); |
|
| 1221 | + } |
|
| 1222 | 1222 | |
| 1223 | 1223 | // Set reply to |
| 1224 | 1224 | $new_notification['post_content']['reply_to'] = $atts['reply_to']; |
| 1225 | 1225 | |
| 1226 | - // Set from |
|
| 1226 | + // Set from |
|
| 1227 | 1227 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
| 1228 | 1228 | $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
| 1229 | - } |
|
| 1230 | - } |
|
| 1229 | + } |
|
| 1230 | + } |
|
| 1231 | 1231 | |
| 1232 | 1232 | /** |
| 1233 | - * Switch field IDs in pre-2.0 email conditional logic |
|
| 1234 | - * |
|
| 1235 | - * @param $post_content array, pass by reference |
|
| 1236 | - */ |
|
| 1233 | + * Switch field IDs in pre-2.0 email conditional logic |
|
| 1234 | + * |
|
| 1235 | + * @param $post_content array, pass by reference |
|
| 1236 | + */ |
|
| 1237 | 1237 | private static function switch_email_contition_field_ids( &$post_content ) { |
| 1238 | 1238 | // Switch field IDs in conditional logic |
| 1239 | 1239 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
@@ -1246,36 +1246,36 @@ discard block |
||
| 1246 | 1246 | } |
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | - private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1250 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
| 1251 | - // migrate autoresponder |
|
| 1252 | - |
|
| 1253 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
| 1254 | - if ( strpos($email_field, '|') ) { |
|
| 1255 | - // data from entries field |
|
| 1256 | - $email_field = explode('|', $email_field); |
|
| 1257 | - if ( isset($email_field[1]) ) { |
|
| 1258 | - $email_field = $email_field[1]; |
|
| 1259 | - } |
|
| 1260 | - } |
|
| 1261 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
| 1249 | + private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1250 | + if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
| 1251 | + // migrate autoresponder |
|
| 1252 | + |
|
| 1253 | + $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
| 1254 | + if ( strpos($email_field, '|') ) { |
|
| 1255 | + // data from entries field |
|
| 1256 | + $email_field = explode('|', $email_field); |
|
| 1257 | + if ( isset($email_field[1]) ) { |
|
| 1258 | + $email_field = $email_field[1]; |
|
| 1259 | + } |
|
| 1260 | + } |
|
| 1261 | + if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
| 1262 | 1262 | $email_field = '[' . $email_field . ']'; |
| 1263 | - } |
|
| 1264 | - |
|
| 1265 | - $notification = $form_options; |
|
| 1266 | - $new_notification2 = array( |
|
| 1267 | - 'post_content' => array( |
|
| 1268 | - 'email_message' => $notification['ar_email_message'], |
|
| 1269 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
| 1270 | - 'email_to' => $email_field, |
|
| 1271 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
| 1272 | - 'inc_user_info' => 0, |
|
| 1273 | - ), |
|
| 1263 | + } |
|
| 1264 | + |
|
| 1265 | + $notification = $form_options; |
|
| 1266 | + $new_notification2 = array( |
|
| 1267 | + 'post_content' => array( |
|
| 1268 | + 'email_message' => $notification['ar_email_message'], |
|
| 1269 | + 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
| 1270 | + 'email_to' => $email_field, |
|
| 1271 | + 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
| 1272 | + 'inc_user_info' => 0, |
|
| 1273 | + ), |
|
| 1274 | 1274 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
| 1275 | - ); |
|
| 1275 | + ); |
|
| 1276 | 1276 | |
| 1277 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
| 1278 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
| 1277 | + $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
| 1278 | + $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
| 1279 | 1279 | |
| 1280 | 1280 | if ( ! empty( $reply_to ) ) { |
| 1281 | 1281 | $new_notification2['post_content']['reply_to'] = $reply_to; |
@@ -1285,9 +1285,9 @@ discard block |
||
| 1285 | 1285 | $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | - $notifications[] = $new_notification2; |
|
| 1289 | - unset( $new_notification2 ); |
|
| 1290 | - } |
|
| 1291 | - } |
|
| 1288 | + $notifications[] = $new_notification2; |
|
| 1289 | + unset( $new_notification2 ); |
|
| 1290 | + } |
|
| 1291 | + } |
|
| 1292 | 1292 | } |
| 1293 | 1293 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | 'terms' => array(), |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | - unset($defaults); |
|
| 43 | + unset( $defaults ); |
|
| 44 | 44 | |
| 45 | 45 | if ( ! defined( 'WP_IMPORTING' ) ) { |
| 46 | - define('WP_IMPORTING', true); |
|
| 46 | + define( 'WP_IMPORTING', true ); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | if ( ! class_exists( 'DOMDocument' ) ) { |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if ( ! function_exists('simplexml_import_dom') ) { |
|
| 59 | + if ( ! function_exists( 'simplexml_import_dom' ) ) { |
|
| 60 | 60 | return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() ); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
| 72 | 72 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
| 73 | 73 | // grab cats, tags, and terms, or forms or posts |
| 74 | - if ( isset($xml->{$item_type} ) ) { |
|
| 74 | + if ( isset( $xml->{$item_type} ) ) { |
|
| 75 | 75 | $function_name = 'import_xml_' . $item_type . 's'; |
| 76 | 76 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
| 77 | 77 | unset( $function_name, $xml->{$item_type} ); |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
| 81 | + $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
|
| 82 | 82 | |
| 83 | 83 | return $return; |
| 84 | 84 | } |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | 'slug' => (string) $t->term_slug, |
| 96 | 96 | 'description' => (string) $t->term_description, |
| 97 | 97 | 'parent' => empty( $parent ) ? 0 : $parent, |
| 98 | - )); |
|
| 98 | + ) ); |
|
| 99 | 99 | |
| 100 | 100 | if ( $term && is_array( $term ) ) { |
| 101 | - $imported['imported']['terms']++; |
|
| 102 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
| 101 | + $imported['imported']['terms'] ++; |
|
| 102 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | unset( $term, $t ); |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | } else { |
| 149 | 149 | $form_id = FrmForm::create( $form ); |
| 150 | 150 | if ( $form_id ) { |
| 151 | - $imported['imported']['forms']++; |
|
| 151 | + $imported['imported']['forms'] ++; |
|
| 152 | 152 | // Keep track of whether this specific form was updated or not |
| 153 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
| 153 | + $imported['form_status'][$form_id] = 'imported'; |
|
| 154 | 154 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | // Update field ids/keys to new ones |
| 163 | 163 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 164 | 164 | |
| 165 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
| 165 | + $imported['forms'][(int) $item->id] = $form_id; |
|
| 166 | 166 | |
| 167 | 167 | // Send pre 2.0 form options through function that creates actions |
| 168 | 168 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
| 169 | 169 | |
| 170 | 170 | do_action( 'frm_after_import_form', $form_id, $form ); |
| 171 | 171 | |
| 172 | - unset($form, $item); |
|
| 172 | + unset( $form, $item ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
@@ -214,18 +214,18 @@ discard block |
||
| 214 | 214 | private static function update_form( $this_form, $form, &$imported ) { |
| 215 | 215 | $form_id = $this_form->id; |
| 216 | 216 | FrmForm::update( $form_id, $form ); |
| 217 | - $imported['updated']['forms']++; |
|
| 217 | + $imported['updated']['forms'] ++; |
|
| 218 | 218 | // Keep track of whether this specific form was updated or not |
| 219 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
| 219 | + $imported['form_status'][$form_id] = 'updated'; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | private static function get_form_fields( $form_id ) { |
| 223 | 223 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
| 224 | 224 | $old_fields = array(); |
| 225 | 225 | foreach ( $form_fields as $f ) { |
| 226 | - $old_fields[ $f->id ] = $f; |
|
| 227 | - $old_fields[ $f->field_key ] = $f->id; |
|
| 228 | - unset($f); |
|
| 226 | + $old_fields[$f->id] = $f; |
|
| 227 | + $old_fields[$f->field_key] = $f->id; |
|
| 228 | + unset( $f ); |
|
| 229 | 229 | } |
| 230 | 230 | $form_fields = $old_fields; |
| 231 | 231 | return $form_fields; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | $regular_forms = array(); |
| 257 | 257 | |
| 258 | 258 | foreach ( $forms as $form ) { |
| 259 | - $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0; |
|
| 259 | + $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0; |
|
| 260 | 260 | |
| 261 | 261 | if ( $parent_form_id ) { |
| 262 | 262 | $child_forms[] = $form; |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 280 | 280 | if ( $parent_form_id ) { |
| 281 | - $child_forms[ $form_id ] = $parent_form_id; |
|
| 281 | + $child_forms[$form_id] = $parent_form_id; |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
@@ -293,9 +293,9 @@ discard block |
||
| 293 | 293 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 294 | 294 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 295 | 295 | |
| 296 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
| 296 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
| 297 | 297 | // Update all children with this old parent_form_id |
| 298 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
| 298 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
| 299 | 299 | |
| 300 | 300 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
| 301 | 301 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | foreach ( $xml_fields as $field ) { |
| 315 | 315 | $f = self::fill_field( $field, $form_id ); |
| 316 | 316 | |
| 317 | - $has_default = array( 'text', 'email', 'url', 'textarea', 'number','phone', 'date', 'hidden', 'password', 'tag', 'image' ); |
|
| 317 | + $has_default = array( 'text', 'email', 'url', 'textarea', 'number', 'phone', 'date', 'hidden', 'password', 'tag', 'image' ); |
|
| 318 | 318 | if ( is_array( $f['default_value'] ) && in_array( $f['type'], $has_default, true ) ) { |
| 319 | 319 | if ( count( $f['default_value'] ) === 1 ) { |
| 320 | 320 | $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
@@ -327,27 +327,27 @@ discard block |
||
| 327 | 327 | self::maybe_update_form_select( $f, $imported ); |
| 328 | 328 | self::maybe_update_get_values_form_setting( $imported, $f ); |
| 329 | 329 | |
| 330 | - if ( ! empty($this_form) ) { |
|
| 330 | + if ( ! empty( $this_form ) ) { |
|
| 331 | 331 | // check for field to edit by field id |
| 332 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
| 332 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
| 333 | 333 | FrmField::update( $f['id'], $f ); |
| 334 | - $imported['updated']['fields']++; |
|
| 334 | + $imported['updated']['fields'] ++; |
|
| 335 | 335 | |
| 336 | - unset( $form_fields[ $f['id'] ] ); |
|
| 336 | + unset( $form_fields[$f['id']] ); |
|
| 337 | 337 | |
| 338 | 338 | //unset old field key |
| 339 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 340 | - unset( $form_fields[ $f['field_key'] ] ); |
|
| 339 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 340 | + unset( $form_fields[$f['field_key']] ); |
|
| 341 | 341 | } |
| 342 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 342 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 343 | 343 | // check for field to edit by field key |
| 344 | - unset($f['id']); |
|
| 344 | + unset( $f['id'] ); |
|
| 345 | 345 | |
| 346 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
| 347 | - $imported['updated']['fields']++; |
|
| 346 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
| 347 | + $imported['updated']['fields'] ++; |
|
| 348 | 348 | |
| 349 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
| 350 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
| 349 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
| 350 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
| 351 | 351 | } else { |
| 352 | 352 | // if no matching field id or key in this form, create the field |
| 353 | 353 | self::create_imported_field( $f, $imported ); |
@@ -366,11 +366,11 @@ discard block |
||
| 366 | 366 | 'name' => (string) $field->name, |
| 367 | 367 | 'description' => (string) $field->description, |
| 368 | 368 | 'type' => (string) $field->type, |
| 369 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
| 369 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ), |
|
| 370 | 370 | 'field_order' => (int) $field->field_order, |
| 371 | 371 | 'form_id' => (int) $form_id, |
| 372 | 372 | 'required' => (int) $field->required, |
| 373 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
| 373 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ), |
|
| 374 | 374 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
| 375 | 375 | ); |
| 376 | 376 | } |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
| 415 | 415 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
| 416 | 416 | $form_select = (int) $f['field_options']['form_select']; |
| 417 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
| 418 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
| 417 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
| 418 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | } |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | |
| 436 | 436 | if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) { |
| 437 | 437 | $old_form = $f['field_options']['get_values_form']; |
| 438 | - if ( isset( $imported['forms'][ $old_form ] ) ) { |
|
| 439 | - $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ]; |
|
| 438 | + if ( isset( $imported['forms'][$old_form] ) ) { |
|
| 439 | + $f['field_options']['get_values_form'] = $imported['forms'][$old_form]; |
|
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | private static function create_imported_field( $f, &$imported ) { |
| 452 | 452 | $new_id = FrmField::create( $f ); |
| 453 | 453 | if ( $new_id != false ) { |
| 454 | - $imported['imported']['fields']++; |
|
| 454 | + $imported['imported']['fields'] ++; |
|
| 455 | 455 | do_action( 'frm_after_field_is_imported', $f, $new_id ); |
| 456 | 456 | } |
| 457 | 457 | } |
@@ -550,9 +550,9 @@ discard block |
||
| 550 | 550 | ); |
| 551 | 551 | |
| 552 | 552 | $old_id = $post['post_id']; |
| 553 | - self::populate_post($post, $item, $imported); |
|
| 553 | + self::populate_post( $post, $item, $imported ); |
|
| 554 | 554 | |
| 555 | - unset($item); |
|
| 555 | + unset( $item ); |
|
| 556 | 556 | |
| 557 | 557 | $post_id = false; |
| 558 | 558 | if ( $post['post_type'] == $form_action_type ) { |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | if ( $action_control && is_object( $action_control ) ) { |
| 561 | 561 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
| 562 | 562 | } |
| 563 | - unset($action_control); |
|
| 563 | + unset( $action_control ); |
|
| 564 | 564 | } else if ( $post['post_type'] == 'frm_styles' ) { |
| 565 | 565 | // Properly encode post content before inserting the post |
| 566 | 566 | $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
@@ -575,24 +575,24 @@ discard block |
||
| 575 | 575 | $post_id = wp_insert_post( $post ); |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - if ( ! is_numeric($post_id) ) { |
|
| 578 | + if ( ! is_numeric( $post_id ) ) { |
|
| 579 | 579 | continue; |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - self::update_postmeta($post, $post_id); |
|
| 582 | + self::update_postmeta( $post, $post_id ); |
|
| 583 | 583 | |
| 584 | 584 | $this_type = 'posts'; |
| 585 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
| 586 | - $this_type = $post_types[ $post['post_type'] ]; |
|
| 585 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
| 586 | + $this_type = $post_types[$post['post_type']]; |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
| 590 | - $imported['updated'][ $this_type ]++; |
|
| 589 | + if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
|
| 590 | + $imported['updated'][$this_type] ++; |
|
| 591 | 591 | } else { |
| 592 | - $imported['imported'][ $this_type ]++; |
|
| 592 | + $imported['imported'][$this_type] ++; |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
| 595 | + $imported['posts'][(int) $old_id] = $post_id; |
|
| 596 | 596 | |
| 597 | 597 | do_action( 'frm_after_import_view', $post_id, $post ); |
| 598 | 598 | |
@@ -605,13 +605,13 @@ discard block |
||
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | private static function populate_post( &$post, $item, $imported ) { |
| 608 | - if ( isset($item->attachment_url) ) { |
|
| 608 | + if ( isset( $item->attachment_url ) ) { |
|
| 609 | 609 | $post['attachment_url'] = (string) $item->attachment_url; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
| 612 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
| 613 | 613 | // update to new form id |
| 614 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 614 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | // Don't allow default styles to take over a site's default style |
@@ -620,13 +620,13 @@ discard block |
||
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | foreach ( $item->postmeta as $meta ) { |
| 623 | - self::populate_postmeta($post, $meta, $imported); |
|
| 624 | - unset($meta); |
|
| 623 | + self::populate_postmeta( $post, $meta, $imported ); |
|
| 624 | + unset( $meta ); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - self::populate_taxonomies($post, $item); |
|
| 627 | + self::populate_taxonomies( $post, $item ); |
|
| 628 | 628 | |
| 629 | - self::maybe_editing_post($post); |
|
| 629 | + self::maybe_editing_post( $post ); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | private static function populate_postmeta( &$post, $meta, $imported ) { |
@@ -638,27 +638,27 @@ discard block |
||
| 638 | 638 | ); |
| 639 | 639 | |
| 640 | 640 | //switch old form and field ids to new ones |
| 641 | - if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
|
| 642 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 641 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
| 642 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
| 643 | 643 | } else { |
| 644 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 644 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 645 | 645 | |
| 646 | - if ( ! empty($frm_duplicate_ids) ) { |
|
| 646 | + if ( ! empty( $frm_duplicate_ids ) ) { |
|
| 647 | 647 | |
| 648 | 648 | if ( $m['key'] == 'frm_dyncontent' ) { |
| 649 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
| 649 | + $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
|
| 650 | 650 | } else if ( $m['key'] == 'frm_options' ) { |
| 651 | 651 | |
| 652 | 652 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 653 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
| 654 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
| 653 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
| 654 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | $check_dup_array = array(); |
| 659 | 659 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
| 660 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 661 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 660 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
| 661 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
| 662 | 662 | } else if ( is_array( $m['value']['order_by'] ) ) { |
| 663 | 663 | $check_dup_array[] = 'order_by'; |
| 664 | 664 | } |
@@ -669,22 +669,22 @@ discard block |
||
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | foreach ( $check_dup_array as $check_k ) { |
| 672 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
| 673 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
| 674 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
| 672 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
| 673 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
| 674 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
| 675 | 675 | } |
| 676 | - unset($mk, $mv); |
|
| 676 | + unset( $mk, $mv ); |
|
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - if ( ! is_array($m['value']) ) { |
|
| 684 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 683 | + if ( ! is_array( $m['value'] ) ) { |
|
| 684 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
| 687 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | /** |
@@ -700,23 +700,23 @@ discard block |
||
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | $taxonomy = (string) $att['domain']; |
| 703 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
| 703 | + if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
| 704 | 704 | $name = (string) $att['nicename']; |
| 705 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
| 705 | + $h_term = get_term_by( 'slug', $name, $taxonomy ); |
|
| 706 | 706 | if ( $h_term ) { |
| 707 | 707 | $name = $h_term->term_id; |
| 708 | 708 | } |
| 709 | - unset($h_term); |
|
| 709 | + unset( $h_term ); |
|
| 710 | 710 | } else { |
| 711 | 711 | $name = (string) $c; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
| 715 | - $post['tax_input'][ $taxonomy ] = array(); |
|
| 714 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
| 715 | + $post['tax_input'][$taxonomy] = array(); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
| 719 | - unset($name); |
|
| 718 | + $post['tax_input'][$taxonomy][] = $name; |
|
| 719 | + unset( $name ); |
|
| 720 | 720 | } |
| 721 | 721 | } |
| 722 | 722 | |
@@ -733,29 +733,29 @@ discard block |
||
| 733 | 733 | |
| 734 | 734 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
| 735 | 735 | $match_by['include'] = $post['post_id']; |
| 736 | - unset($match_by['name']); |
|
| 736 | + unset( $match_by['name'] ); |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | - $editing = get_posts($match_by); |
|
| 739 | + $editing = get_posts( $match_by ); |
|
| 740 | 740 | |
| 741 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
| 741 | + if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) { |
|
| 742 | 742 | // set the id of the post to edit |
| 743 | - $post['ID'] = current($editing)->ID; |
|
| 743 | + $post['ID'] = current( $editing )->ID; |
|
| 744 | 744 | } |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | private static function update_postmeta( &$post, $post_id ) { |
| 748 | 748 | foreach ( $post['postmeta'] as $k => $v ) { |
| 749 | 749 | if ( '_edit_last' == $k ) { |
| 750 | - $v = FrmAppHelper::get_user_id_param($v); |
|
| 750 | + $v = FrmAppHelper::get_user_id_param( $v ); |
|
| 751 | 751 | } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
| 752 | 752 | //change the attachment ID |
| 753 | - $v = FrmProXMLHelper::get_file_id($v); |
|
| 753 | + $v = FrmProXMLHelper::get_file_id( $v ); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | - update_post_meta($post_id, $k, $v); |
|
| 756 | + update_post_meta( $post_id, $k, $v ); |
|
| 757 | 757 | |
| 758 | - unset($k, $v); |
|
| 758 | + unset( $k, $v ); |
|
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | 761 | |
@@ -794,13 +794,13 @@ discard block |
||
| 794 | 794 | * @param string $message |
| 795 | 795 | */ |
| 796 | 796 | public static function parse_message( $result, &$message, &$errors ) { |
| 797 | - if ( is_wp_error($result) ) { |
|
| 797 | + if ( is_wp_error( $result ) ) { |
|
| 798 | 798 | $errors[] = $result->get_error_message(); |
| 799 | 799 | } else if ( ! $result ) { |
| 800 | 800 | return; |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | - if ( ! is_array($result) ) { |
|
| 803 | + if ( ! is_array( $result ) ) { |
|
| 804 | 804 | $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) ); |
| 805 | 805 | return; |
| 806 | 806 | } |
@@ -812,20 +812,20 @@ discard block |
||
| 812 | 812 | |
| 813 | 813 | $message = '<ul>'; |
| 814 | 814 | foreach ( $result as $type => $results ) { |
| 815 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
| 815 | + if ( ! isset( $t_strings[$type] ) ) { |
|
| 816 | 816 | // only print imported and updated |
| 817 | 817 | continue; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | $s_message = array(); |
| 821 | 821 | foreach ( $results as $k => $m ) { |
| 822 | - self::item_count_message($m, $k, $s_message); |
|
| 823 | - unset($k, $m); |
|
| 822 | + self::item_count_message( $m, $k, $s_message ); |
|
| 823 | + unset( $k, $m ); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if ( ! empty($s_message) ) { |
|
| 827 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
| 828 | - $message .= implode(', ', $s_message); |
|
| 826 | + if ( ! empty( $s_message ) ) { |
|
| 827 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
| 828 | + $message .= implode( ', ', $s_message ); |
|
| 829 | 829 | $message .= '</li>'; |
| 830 | 830 | } |
| 831 | 831 | } |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
| 855 | 855 | ); |
| 856 | 856 | |
| 857 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 857 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | /** |
@@ -886,14 +886,14 @@ discard block |
||
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | public static function cdata( $str ) { |
| 889 | - $str = maybe_unserialize($str); |
|
| 890 | - if ( is_array($str) ) { |
|
| 891 | - $str = json_encode($str); |
|
| 889 | + $str = maybe_unserialize( $str ); |
|
| 890 | + if ( is_array( $str ) ) { |
|
| 891 | + $str = json_encode( $str ); |
|
| 892 | 892 | } else if ( seems_utf8( $str ) == false ) { |
| 893 | 893 | $str = utf8_encode( $str ); |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | - if ( is_numeric($str) ) { |
|
| 896 | + if ( is_numeric( $str ) ) { |
|
| 897 | 897 | return $str; |
| 898 | 898 | } |
| 899 | 899 | |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | * @param string $post_type |
| 939 | 939 | */ |
| 940 | 940 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
| 941 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
| 941 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
| 942 | 942 | return; |
| 943 | 943 | } |
| 944 | 944 | |
@@ -955,10 +955,10 @@ discard block |
||
| 955 | 955 | $post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' ); |
| 956 | 956 | |
| 957 | 957 | foreach ( $post_settings as $post_setting ) { |
| 958 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
| 959 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
| 958 | + if ( isset( $form_options[$post_setting] ) ) { |
|
| 959 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
| 960 | 960 | } |
| 961 | - unset($post_setting); |
|
| 961 | + unset( $post_setting ); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | $new_action['event'] = array( 'create', 'update' ); |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | |
| 973 | 973 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
| 974 | 974 | } |
| 975 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
| 975 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
| 976 | 976 | |
| 977 | 977 | $exists = get_posts( array( |
| 978 | 978 | 'name' => $new_action['post_name'], |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | if ( ! $exists ) { |
| 985 | 985 | // this isn't an email, but we need to use a class that will always be included |
| 986 | 986 | FrmDb::save_json_post( $new_action ); |
| 987 | - $imported['imported']['actions']++; |
|
| 987 | + $imported['imported']['actions'] ++; |
|
| 988 | 988 | } |
| 989 | 989 | } |
| 990 | 990 | |
@@ -1016,11 +1016,11 @@ discard block |
||
| 1016 | 1016 | foreach ( $post_content as $key => $setting ) { |
| 1017 | 1017 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
| 1018 | 1018 | // Replace old IDs with new IDs |
| 1019 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
| 1019 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
| 1020 | 1020 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
| 1021 | 1021 | foreach ( $setting as $k => $val ) { |
| 1022 | 1022 | // Replace old IDs with new IDs |
| 1023 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
| 1023 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | unset( $key, $setting ); |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | foreach ( $notifications as $new_notification ) { |
| 1051 | 1051 | $new_notification['post_type'] = $post_type; |
| 1052 | 1052 | $new_notification['post_excerpt'] = 'email'; |
| 1053 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 1053 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 1054 | 1054 | $new_notification['menu_order'] = $form_id; |
| 1055 | 1055 | $new_notification['post_status'] = 'publish'; |
| 1056 | 1056 | |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | // Switch all other field IDs in email |
| 1064 | 1064 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
| 1065 | 1065 | } |
| 1066 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1066 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1067 | 1067 | |
| 1068 | 1068 | $exists = get_posts( array( |
| 1069 | 1069 | 'name' => $new_notification['post_name'], |
@@ -1072,11 +1072,11 @@ discard block |
||
| 1072 | 1072 | 'numberposts' => 1, |
| 1073 | 1073 | ) ); |
| 1074 | 1074 | |
| 1075 | - if ( empty($exists) ) { |
|
| 1075 | + if ( empty( $exists ) ) { |
|
| 1076 | 1076 | FrmDb::save_json_post( $new_notification ); |
| 1077 | - $imported['imported']['actions']++; |
|
| 1077 | + $imported['imported']['actions'] ++; |
|
| 1078 | 1078 | } |
| 1079 | - unset($new_notification); |
|
| 1079 | + unset( $new_notification ); |
|
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | 1082 | self::remove_deprecated_notification_settings( $form_id, $form_options ); |
@@ -1093,8 +1093,8 @@ discard block |
||
| 1093 | 1093 | private static function remove_deprecated_notification_settings( $form_id, $form_options ) { |
| 1094 | 1094 | $delete_settings = array( 'notification', 'autoresponder', 'email_to' ); |
| 1095 | 1095 | foreach ( $delete_settings as $index ) { |
| 1096 | - if ( isset( $form_options[ $index ] ) ) { |
|
| 1097 | - unset( $form_options[ $index ] ); |
|
| 1096 | + if ( isset( $form_options[$index] ) ) { |
|
| 1097 | + unset( $form_options[$index] ); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | } |
| 1100 | 1100 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
| 1112 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
| 1113 | 1113 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
| 1114 | 1114 | |
| 1115 | 1115 | $atts = array( |
@@ -1147,12 +1147,12 @@ discard block |
||
| 1147 | 1147 | 'reply_to_name' => '', |
| 1148 | 1148 | ); |
| 1149 | 1149 | foreach ( $reply_fields as $f => $val ) { |
| 1150 | - if ( isset( $notification[ $f ] ) ) { |
|
| 1151 | - $atts[ $f ] = $notification[ $f ]; |
|
| 1152 | - if ( 'custom' == $notification[ $f ] ) { |
|
| 1153 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
| 1154 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
| 1155 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
| 1150 | + if ( isset( $notification[$f] ) ) { |
|
| 1151 | + $atts[$f] = $notification[$f]; |
|
| 1152 | + if ( 'custom' == $notification[$f] ) { |
|
| 1153 | + $atts[$f] = $notification['cust_' . $f]; |
|
| 1154 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
| 1155 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
| 1156 | 1156 | } |
| 1157 | 1157 | } |
| 1158 | 1158 | unset( $f, $val ); |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | $atts['event'] = array( 'create' ); |
| 1163 | 1163 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
| 1164 | 1164 | $atts['event'][] = 'update'; |
| 1165 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
| 1165 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
| 1166 | 1166 | $atts['event'] = array( 'update' ); |
| 1167 | 1167 | } |
| 1168 | 1168 | } |
@@ -1183,18 +1183,18 @@ discard block |
||
| 1183 | 1183 | foreach ( $atts['email_to'] as $key => $email_field ) { |
| 1184 | 1184 | |
| 1185 | 1185 | if ( is_numeric( $email_field ) ) { |
| 1186 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
| 1186 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | - if ( strpos( $email_field, '|') ) { |
|
| 1189 | + if ( strpos( $email_field, '|' ) ) { |
|
| 1190 | 1190 | $email_opt = explode( '|', $email_field ); |
| 1191 | 1191 | if ( isset( $email_opt[0] ) ) { |
| 1192 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 1192 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 1193 | 1193 | } |
| 1194 | 1194 | unset( $email_opt ); |
| 1195 | 1195 | } |
| 1196 | 1196 | } |
| 1197 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
| 1197 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -1210,12 +1210,12 @@ discard block |
||
| 1210 | 1210 | // Add more fields to the new notification |
| 1211 | 1211 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
| 1212 | 1212 | foreach ( $add_fields as $add_field ) { |
| 1213 | - if ( isset( $notification[ $add_field ] ) ) { |
|
| 1214 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
| 1213 | + if ( isset( $notification[$add_field] ) ) { |
|
| 1214 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
| 1215 | 1215 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
| 1216 | - $new_notification['post_content'][ $add_field ] = 0; |
|
| 1216 | + $new_notification['post_content'][$add_field] = 0; |
|
| 1217 | 1217 | } else { |
| 1218 | - $new_notification['post_content'][ $add_field ] = ''; |
|
| 1218 | + $new_notification['post_content'][$add_field] = ''; |
|
| 1219 | 1219 | } |
| 1220 | 1220 | unset( $add_field ); |
| 1221 | 1221 | } |
@@ -1239,26 +1239,26 @@ discard block |
||
| 1239 | 1239 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
| 1240 | 1240 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
| 1241 | 1241 | if ( is_numeric( $email_key ) ) { |
| 1242 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1242 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1243 | 1243 | } |
| 1244 | - unset( $email_key, $val); |
|
| 1244 | + unset( $email_key, $val ); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | 1249 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
| 1250 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
| 1250 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
| 1251 | 1251 | // migrate autoresponder |
| 1252 | 1252 | |
| 1253 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
| 1254 | - if ( strpos($email_field, '|') ) { |
|
| 1253 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
| 1254 | + if ( strpos( $email_field, '|' ) ) { |
|
| 1255 | 1255 | // data from entries field |
| 1256 | - $email_field = explode('|', $email_field); |
|
| 1257 | - if ( isset($email_field[1]) ) { |
|
| 1256 | + $email_field = explode( '|', $email_field ); |
|
| 1257 | + if ( isset( $email_field[1] ) ) { |
|
| 1258 | 1258 | $email_field = $email_field[1]; |
| 1259 | 1259 | } |
| 1260 | 1260 | } |
| 1261 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
| 1261 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
| 1262 | 1262 | $email_field = '[' . $email_field . ']'; |
| 1263 | 1263 | } |
| 1264 | 1264 | |
@@ -1266,16 +1266,16 @@ discard block |
||
| 1266 | 1266 | $new_notification2 = array( |
| 1267 | 1267 | 'post_content' => array( |
| 1268 | 1268 | 'email_message' => $notification['ar_email_message'], |
| 1269 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
| 1269 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
| 1270 | 1270 | 'email_to' => $email_field, |
| 1271 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
| 1271 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
| 1272 | 1272 | 'inc_user_info' => 0, |
| 1273 | 1273 | ), |
| 1274 | 1274 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
| 1275 | 1275 | ); |
| 1276 | 1276 | |
| 1277 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
| 1278 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
| 1277 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
| 1278 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
| 1279 | 1279 | |
| 1280 | 1280 | if ( ! empty( $reply_to ) ) { |
| 1281 | 1281 | $new_notification2['post_content']['reply_to'] = $reply_to; |
@@ -1,67 +1,67 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStylesHelper { |
| 3 | 3 | |
| 4 | - public static function jquery_themes() { |
|
| 5 | - $themes = array( |
|
| 6 | - 'ui-lightness' => 'UI Lightness', |
|
| 7 | - 'ui-darkness' => 'UI Darkness', |
|
| 8 | - 'smoothness' => 'Smoothness', |
|
| 9 | - 'start' => 'Start', |
|
| 10 | - 'redmond' => 'Redmond', |
|
| 11 | - 'sunny' => 'Sunny', |
|
| 12 | - 'overcast' => 'Overcast', |
|
| 13 | - 'le-frog' => 'Le Frog', |
|
| 14 | - 'flick' => 'Flick', |
|
| 4 | + public static function jquery_themes() { |
|
| 5 | + $themes = array( |
|
| 6 | + 'ui-lightness' => 'UI Lightness', |
|
| 7 | + 'ui-darkness' => 'UI Darkness', |
|
| 8 | + 'smoothness' => 'Smoothness', |
|
| 9 | + 'start' => 'Start', |
|
| 10 | + 'redmond' => 'Redmond', |
|
| 11 | + 'sunny' => 'Sunny', |
|
| 12 | + 'overcast' => 'Overcast', |
|
| 13 | + 'le-frog' => 'Le Frog', |
|
| 14 | + 'flick' => 'Flick', |
|
| 15 | 15 | 'pepper-grinder' => 'Pepper Grinder', |
| 16 | - 'eggplant' => 'Eggplant', |
|
| 17 | - 'dark-hive' => 'Dark Hive', |
|
| 18 | - 'cupertino' => 'Cupertino', |
|
| 19 | - 'south-street' => 'South Street', |
|
| 20 | - 'blitzer' => 'Blitzer', |
|
| 21 | - 'humanity' => 'Humanity', |
|
| 22 | - 'hot-sneaks' => 'Hot Sneaks', |
|
| 23 | - 'excite-bike' => 'Excite Bike', |
|
| 24 | - 'vader' => 'Vader', |
|
| 25 | - 'dot-luv' => 'Dot Luv', |
|
| 26 | - 'mint-choc' => 'Mint Choc', |
|
| 27 | - 'black-tie' => 'Black Tie', |
|
| 28 | - 'trontastic' => 'Trontastic', |
|
| 29 | - 'swanky-purse' => 'Swanky Purse', |
|
| 30 | - ); |
|
| 31 | - |
|
| 32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 33 | - return $themes; |
|
| 34 | - } |
|
| 16 | + 'eggplant' => 'Eggplant', |
|
| 17 | + 'dark-hive' => 'Dark Hive', |
|
| 18 | + 'cupertino' => 'Cupertino', |
|
| 19 | + 'south-street' => 'South Street', |
|
| 20 | + 'blitzer' => 'Blitzer', |
|
| 21 | + 'humanity' => 'Humanity', |
|
| 22 | + 'hot-sneaks' => 'Hot Sneaks', |
|
| 23 | + 'excite-bike' => 'Excite Bike', |
|
| 24 | + 'vader' => 'Vader', |
|
| 25 | + 'dot-luv' => 'Dot Luv', |
|
| 26 | + 'mint-choc' => 'Mint Choc', |
|
| 27 | + 'black-tie' => 'Black Tie', |
|
| 28 | + 'trontastic' => 'Trontastic', |
|
| 29 | + 'swanky-purse' => 'Swanky Purse', |
|
| 30 | + ); |
|
| 31 | + |
|
| 32 | + $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 33 | + return $themes; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | public static function jquery_css_url( $theme_css ) { |
| 37 | - if ( $theme_css == -1 ) { |
|
| 38 | - return; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
| 42 | - $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
| 43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 44 | - $css_file = $theme_css; |
|
| 45 | - } else { |
|
| 46 | - $uploads = self::get_upload_base(); |
|
| 37 | + if ( $theme_css == -1 ) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
| 42 | + $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
| 43 | + } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 44 | + $css_file = $theme_css; |
|
| 45 | + } else { |
|
| 46 | + $uploads = self::get_upload_base(); |
|
| 47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
| 48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 49 | - $css_file = $uploads['baseurl'] . $file_path; |
|
| 50 | - } else { |
|
| 48 | + if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 49 | + $css_file = $uploads['baseurl'] . $file_path; |
|
| 50 | + } else { |
|
| 51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
| 52 | - } |
|
| 53 | - } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $css_file; |
|
| 56 | - } |
|
| 55 | + return $css_file; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public static function enqueue_jquery_css() { |
|
| 58 | + public static function enqueue_jquery_css() { |
|
| 59 | 59 | $form = self::get_form_for_page(); |
| 60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
| 61 | - if ( $theme_css != -1 ) { |
|
| 62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 63 | - } |
|
| 64 | - } |
|
| 61 | + if ( $theme_css != -1 ) { |
|
| 62 | + wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | public static function get_form_for_page() { |
| 67 | 67 | global $frm_vars; |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | return $form_id; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public static function get_upload_base() { |
|
| 81 | - $uploads = wp_upload_dir(); |
|
| 82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 84 | - } |
|
| 80 | + public static function get_upload_base() { |
|
| 81 | + $uploads = wp_upload_dir(); |
|
| 82 | + if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return $uploads; |
|
| 87 | - } |
|
| 86 | + return $uploads; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | public static function style_menu( $active = '' ) { |
| 90 | 90 | ?> |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ) ?></a> |
| 95 | 95 | </h2> |
| 96 | 96 | <?php |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @since 2.05 |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | ); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - /** |
|
| 190 | - * @since 2.0 |
|
| 191 | - * @return The class for this icon |
|
| 192 | - */ |
|
| 189 | + /** |
|
| 190 | + * @since 2.0 |
|
| 191 | + * @return The class for this icon |
|
| 192 | + */ |
|
| 193 | 193 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
| 194 | 194 | if ( 'arrow' == $type && is_numeric( $key ) ) { |
| 195 | 195 | //frm_arrowup6_icon |
@@ -205,20 +205,20 @@ discard block |
||
| 205 | 205 | $class = 'frm_' . $plus[ $icon ]; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ( $key ) { |
|
| 209 | - $class .= $key; |
|
| 210 | - } |
|
| 211 | - $class .= '_icon'; |
|
| 208 | + if ( $key ) { |
|
| 209 | + $class .= $key; |
|
| 210 | + } |
|
| 211 | + $class .= '_icon'; |
|
| 212 | 212 | |
| 213 | - return $class; |
|
| 214 | - } |
|
| 213 | + return $class; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) { |
| 217 | 217 | $function_name = $type . '_icons'; |
| 218 | 218 | $icons = self::$function_name(); |
| 219 | 219 | unset( $function_name ); |
| 220 | 220 | |
| 221 | - $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
| 221 | + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
| 222 | 222 | ?> |
| 223 | 223 | <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
| 224 | 224 | <?php foreach ( $icons as $key => $icon ) { ?> |
@@ -251,24 +251,24 @@ discard block |
||
| 251 | 251 | </ul> |
| 252 | 252 | </div> |
| 253 | 253 | <?php |
| 254 | - } |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | 256 | public static function hex2rgb( $hex ) { |
| 257 | - $hex = str_replace('#', '', $hex); |
|
| 257 | + $hex = str_replace('#', '', $hex); |
|
| 258 | 258 | |
| 259 | - if ( strlen($hex) == 3 ) { |
|
| 259 | + if ( strlen($hex) == 3 ) { |
|
| 260 | 260 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
| 261 | 261 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
| 262 | 262 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
| 263 | - } else { |
|
| 263 | + } else { |
|
| 264 | 264 | $r = hexdec( substr( $hex, 0, 2 ) ); |
| 265 | 265 | $g = hexdec( substr( $hex, 2, 2 ) ); |
| 266 | 266 | $b = hexdec( substr( $hex, 4, 2 ) ); |
| 267 | - } |
|
| 267 | + } |
|
| 268 | 268 | $rgb = array( $r, $g, $b ); |
| 269 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 270 | - //return $rgb; // returns an array with the rgb values |
|
| 271 | - } |
|
| 269 | + return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 270 | + //return $rgb; // returns an array with the rgb values |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * @param $hex string - The original color in hex format #ffffff |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | 'swanky-purse' => 'Swanky Purse', |
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 32 | + $themes = apply_filters( 'frm_jquery_themes', $themes ); |
|
| 33 | 33 | return $themes; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
| 42 | 42 | $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
| 43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 43 | + } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) { |
|
| 44 | 44 | $css_file = $theme_css; |
| 45 | 45 | } else { |
| 46 | 46 | $uploads = self::get_upload_base(); |
| 47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
| 48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 48 | + if ( file_exists( $uploads['basedir'] . $file_path ) ) { |
|
| 49 | 49 | $css_file = $uploads['baseurl'] . $file_path; |
| 50 | 50 | } else { |
| 51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $form = self::get_form_for_page(); |
| 60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
| 61 | 61 | if ( $theme_css != -1 ) { |
| 62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 62 | + wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() ); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public static function get_upload_base() { |
| 81 | 81 | $uploads = wp_upload_dir(); |
| 82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 82 | + if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) { |
|
| 83 | + $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $uploads; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | <h2 class="nav-tab-wrapper"> |
| 92 | 92 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Edit Styles', 'formidable' ) ?></a> |
| 93 | 93 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Manage Form Styles', 'formidable' ) ?></a> |
| 94 | - <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ) ?></a> |
|
| 94 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ) ?></a> |
|
| 95 | 95 | </h2> |
| 96 | 96 | <?php |
| 97 | 97 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | if ( 'arrow' == $type && is_numeric( $key ) ) { |
| 195 | 195 | //frm_arrowup6_icon |
| 196 | 196 | $arrow = array( '-' => 'down', '+' => 'up' ); |
| 197 | - $class = 'frm_arrow' . $arrow[ $icon ]; |
|
| 197 | + $class = 'frm_arrow' . $arrow[$icon]; |
|
| 198 | 198 | } else { |
| 199 | 199 | //frm_minus1_icon |
| 200 | 200 | $key = str_replace( 'p', '', $key ); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | '-' => 'minus', |
| 203 | 203 | '+' => 'plus', |
| 204 | 204 | ); |
| 205 | - $class = 'frm_' . $plus[ $icon ]; |
|
| 205 | + $class = 'frm_' . $plus[$icon]; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | if ( $key ) { |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
| 222 | 222 | ?> |
| 223 | - <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
| 223 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
| 224 | 224 | <?php foreach ( $icons as $key => $icon ) { ?> |
| 225 | - <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>> |
|
| 225 | + <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>> |
|
| 226 | 226 | <?php echo '' . $icon['+'] . '; ' . $icon['-'] . ';'; ?> |
| 227 | 227 | </option> |
| 228 | 228 | <?php } ?> |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select"> |
| 232 | 232 | <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> |
| 233 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i> |
|
| 234 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i> |
|
| 233 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i> |
|
| 234 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i> |
|
| 235 | 235 | <b class="caret"></b> |
| 236 | 236 | </button> |
| 237 | 237 | <ul class="multiselect-container frm-dropdown-menu"> |
@@ -254,9 +254,9 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | public static function hex2rgb( $hex ) { |
| 257 | - $hex = str_replace('#', '', $hex); |
|
| 257 | + $hex = str_replace( '#', '', $hex ); |
|
| 258 | 258 | |
| 259 | - if ( strlen($hex) == 3 ) { |
|
| 259 | + if ( strlen( $hex ) == 3 ) { |
|
| 260 | 260 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
| 261 | 261 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
| 262 | 262 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $b = hexdec( substr( $hex, 4, 2 ) ); |
| 267 | 267 | } |
| 268 | 268 | $rgb = array( $r, $g, $b ); |
| 269 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 269 | + return implode( ',', $rgb ); // returns the rgb values separated by commas |
|
| 270 | 270 | //return $rgb; // returns an array with the rgb values |
| 271 | 271 | } |
| 272 | 272 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * @since 2.3 |
| 277 | 277 | */ |
| 278 | 278 | public static function adjust_brightness( $hex, $steps ) { |
| 279 | - $steps = max( -255, min( 255, $steps ) ); |
|
| 279 | + $steps = max( - 255, min( 255, $steps ) ); |
|
| 280 | 280 | |
| 281 | 281 | // Normalize into a six character long hex string |
| 282 | 282 | $hex = str_replace( '#', '', $hex ); |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | $checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' ); |
| 329 | 329 | foreach ( $checkbox_opts as $opt ) { |
| 330 | - if ( ! isset( $settings[ $opt ] ) ) { |
|
| 331 | - $settings[ $opt ] = 0; |
|
| 330 | + if ( ! isset( $settings[$opt] ) ) { |
|
| 331 | + $settings[$opt] = 0; |
|
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $colors = self::allow_color_override(); |
| 345 | 345 | foreach ( $colors as $css => $opts ) { |
| 346 | 346 | foreach ( $opts as $opt ) { |
| 347 | - self::get_color_output( $css, $settings[ $opt ] ); |
|
| 347 | + self::get_color_output( $css, $settings[$opt] ); |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | } |