@@ -14,38 +14,38 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public static function get_direct_link( $key, $form = false ) { |
| 16 | 16 | $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) ); |
| 17 | - $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
| 18 | - |
|
| 19 | - return $target_url; |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
| 23 | - $defaults = array( |
|
| 24 | - 'blank' => true, |
|
| 25 | - 'field_id' => false, |
|
| 26 | - 'onchange' => false, |
|
| 27 | - 'exclude' => false, |
|
| 28 | - 'class' => '', |
|
| 17 | + $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
| 18 | + |
|
| 19 | + return $target_url; |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
| 23 | + $defaults = array( |
|
| 24 | + 'blank' => true, |
|
| 25 | + 'field_id' => false, |
|
| 26 | + 'onchange' => false, |
|
| 27 | + 'exclude' => false, |
|
| 28 | + 'class' => '', |
|
| 29 | 29 | 'inc_children' => 'exclude', |
| 30 | - ); |
|
| 31 | - $args = wp_parse_args( $args, $defaults ); |
|
| 30 | + ); |
|
| 31 | + $args = wp_parse_args( $args, $defaults ); |
|
| 32 | 32 | |
| 33 | - if ( ! $args['field_id'] ) { |
|
| 34 | - $args['field_id'] = $field_name; |
|
| 35 | - } |
|
| 33 | + if ( ! $args['field_id'] ) { |
|
| 34 | + $args['field_id'] = $field_name; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | $query = array(); |
| 38 | - if ( $args['exclude'] ) { |
|
| 38 | + if ( $args['exclude'] ) { |
|
| 39 | 39 | $query['id !'] = $args['exclude']; |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
| 42 | + $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
| 43 | 43 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
| 44 | 44 | $add_html = array(); |
| 45 | 45 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
| 46 | 46 | self::add_html_attr( $args['class'], 'class', $add_html ); |
| 47 | 47 | |
| 48 | - ?> |
|
| 48 | + ?> |
|
| 49 | 49 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>> |
| 50 | 50 | <?php if ( $args['blank'] ) { ?> |
| 51 | 51 | <option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option> |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | <?php } ?> |
| 58 | 58 | </select> |
| 59 | 59 | <?php |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @param string $class |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public static function form_switcher() { |
|
| 75 | + public static function form_switcher() { |
|
| 76 | 76 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 77 | 77 | $forms = FrmForm::get_published_forms( $where ); |
| 78 | 78 | |
@@ -84,32 +84,32 @@ discard block |
||
| 84 | 84 | unset( $args['form'] ); |
| 85 | 85 | } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) { |
| 86 | 86 | unset( $args['id'] ); |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 90 | 90 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
| 91 | - $args['frm_action'] = 'list'; |
|
| 92 | - $args['form'] = 0; |
|
| 91 | + $args['frm_action'] = 'list'; |
|
| 92 | + $args['form'] = 0; |
|
| 93 | 93 | } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
| 94 | - $args['frm_action'] = 'edit'; |
|
| 94 | + $args['frm_action'] = 'edit'; |
|
| 95 | 95 | } else if ( isset( $_GET['post'] ) ) { |
| 96 | - $args['form'] = 0; |
|
| 97 | - $base = admin_url('edit.php?post_type=frm_display'); |
|
| 98 | - } |
|
| 96 | + $args['form'] = 0; |
|
| 97 | + $base = admin_url('edit.php?post_type=frm_display'); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - ?> |
|
| 100 | + ?> |
|
| 101 | 101 | <li id="frm_bs_dropdown" class="dropdown <?php echo esc_attr( is_rtl() ? 'pull-right' : 'pull-left' ) ?>"> |
| 102 | 102 | <a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php esc_html_e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a> |
| 103 | 103 | <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop"> |
| 104 | 104 | <?php |
| 105 | 105 | foreach ( $forms as $form ) { |
| 106 | 106 | if ( isset( $args['id'] ) ) { |
| 107 | - $args['id'] = $form->id; |
|
| 107 | + $args['id'] = $form->id; |
|
| 108 | 108 | } |
| 109 | - if ( isset( $args['form'] ) ) { |
|
| 110 | - $args['form'] = $form->id; |
|
| 109 | + if ( isset( $args['form'] ) ) { |
|
| 110 | + $args['form'] = $form->id; |
|
| 111 | 111 | } |
| 112 | - ?> |
|
| 112 | + ?> |
|
| 113 | 113 | <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li> |
| 114 | 114 | <?php |
| 115 | 115 | unset( $form ); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | </ul> |
| 119 | 119 | </li> |
| 120 | 120 | <?php |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | public static function get_sortable_classes( $col, $sort_col, $sort_dir ) { |
| 124 | 124 | echo ( $sort_col == $col ) ? 'sorted' : 'sortable'; |
@@ -171,18 +171,18 @@ discard block |
||
| 171 | 171 | return $message; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - /** |
|
| 175 | - * Used when a form is created |
|
| 176 | - */ |
|
| 177 | - public static function setup_new_vars( $values = array() ) { |
|
| 178 | - global $wpdb; |
|
| 174 | + /** |
|
| 175 | + * Used when a form is created |
|
| 176 | + */ |
|
| 177 | + public static function setup_new_vars( $values = array() ) { |
|
| 178 | + global $wpdb; |
|
| 179 | 179 | |
| 180 | - if ( ! empty( $values ) ) { |
|
| 181 | - $post_values = $values; |
|
| 182 | - } else { |
|
| 183 | - $values = array(); |
|
| 184 | - $post_values = isset($_POST) ? $_POST : array(); |
|
| 185 | - } |
|
| 180 | + if ( ! empty( $values ) ) { |
|
| 181 | + $post_values = $values; |
|
| 182 | + } else { |
|
| 183 | + $values = array(); |
|
| 184 | + $post_values = isset($_POST) ? $_POST : array(); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | 187 | $defaults = array( |
| 188 | 188 | 'name' => '', |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | foreach ( $defaults as $var => $default ) { |
| 192 | 192 | if ( ! isset( $values[ $var ] ) ) { |
| 193 | 193 | $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
| 194 | - } |
|
| 195 | - } |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
| 197 | + $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
| 198 | 198 | |
| 199 | 199 | $defaults = array( |
| 200 | 200 | 'form_id' => '', |
@@ -212,64 +212,64 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | unset( $defaults ); |
| 214 | 214 | |
| 215 | - if ( ! isset( $values['form_key'] ) ) { |
|
| 215 | + if ( ! isset( $values['form_key'] ) ) { |
|
| 216 | 216 | $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' ); |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | $values = self::fill_default_opts( $values, false, $post_values ); |
| 220 | 220 | $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values ); |
| 221 | 221 | |
| 222 | - return apply_filters('frm_setup_new_form_vars', $values); |
|
| 223 | - } |
|
| 222 | + return apply_filters('frm_setup_new_form_vars', $values); |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - /** |
|
| 226 | - * Used when editing a form |
|
| 227 | - */ |
|
| 228 | - public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
| 225 | + /** |
|
| 226 | + * Used when editing a form |
|
| 227 | + */ |
|
| 228 | + public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
| 229 | 229 | if ( empty( $post_values ) ) { |
| 230 | 230 | $post_values = stripslashes_deep( $_POST ); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
| 234 | - $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
| 235 | - $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
| 236 | - $values['status'] = $record->status; |
|
| 233 | + $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
| 234 | + $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
| 235 | + $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
| 236 | + $values['status'] = $record->status; |
|
| 237 | 237 | |
| 238 | - $values = self::fill_default_opts($values, $record, $post_values); |
|
| 238 | + $values = self::fill_default_opts($values, $record, $post_values); |
|
| 239 | 239 | |
| 240 | - return apply_filters('frm_setup_edit_form_vars', $values); |
|
| 241 | - } |
|
| 240 | + return apply_filters('frm_setup_edit_form_vars', $values); |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | 243 | public static function fill_default_opts( $values, $record, $post_values ) { |
| 244 | 244 | |
| 245 | - $defaults = self::get_default_opts(); |
|
| 245 | + $defaults = self::get_default_opts(); |
|
| 246 | 246 | foreach ( $defaults as $var => $default ) { |
| 247 | - if ( is_array($default) ) { |
|
| 248 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 247 | + if ( is_array($default) ) { |
|
| 248 | + if ( ! isset( $values[ $var ] ) ) { |
|
| 249 | 249 | $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
| 250 | - } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - foreach ( $default as $k => $v ) { |
|
| 252 | + foreach ( $default as $k => $v ) { |
|
| 253 | 253 | $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 ); |
| 254 | 254 | |
| 255 | - if ( is_array( $v ) ) { |
|
| 256 | - foreach ( $v as $k1 => $v1 ) { |
|
| 255 | + if ( is_array( $v ) ) { |
|
| 256 | + foreach ( $v as $k1 => $v1 ) { |
|
| 257 | 257 | $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 ); |
| 258 | - unset( $k1, $v1 ); |
|
| 259 | - } |
|
| 260 | - } |
|
| 258 | + unset( $k1, $v1 ); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - unset($k, $v); |
|
| 263 | - } |
|
| 264 | - } else { |
|
| 262 | + unset($k, $v); |
|
| 263 | + } |
|
| 264 | + } else { |
|
| 265 | 265 | $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
| 266 | - } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - unset($var, $default); |
|
| 269 | - } |
|
| 268 | + unset($var, $default); |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - return $values; |
|
| 272 | - } |
|
| 271 | + return $values; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | public static function get_default_opts() { |
| 275 | 275 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - /** |
|
| 308 | - * @param string $loc |
|
| 309 | - */ |
|
| 307 | + /** |
|
| 308 | + * @param string $loc |
|
| 309 | + */ |
|
| 310 | 310 | public static function get_default_html( $loc ) { |
| 311 | 311 | if ( $loc == 'submit' ) { |
| 312 | - $draft_link = self::get_draft_link(); |
|
| 313 | - $default_html = <<<SUBMIT_HTML |
|
| 312 | + $draft_link = self::get_draft_link(); |
|
| 313 | + $default_html = <<<SUBMIT_HTML |
|
| 314 | 314 | <div class="frm_submit"> |
| 315 | 315 | [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button] |
| 316 | 316 | <button class="frm_button_submit" type="submit" [button_action]>[button_label]</button> |
@@ -318,22 +318,22 @@ discard block |
||
| 318 | 318 | </div> |
| 319 | 319 | SUBMIT_HTML; |
| 320 | 320 | } else if ( $loc == 'before' ) { |
| 321 | - $default_html = <<<BEFORE_HTML |
|
| 321 | + $default_html = <<<BEFORE_HTML |
|
| 322 | 322 | <legend class="frm_screen_reader">[form_name]</legend> |
| 323 | 323 | [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name] |
| 324 | 324 | [if form_description]<div class="frm_description">[form_description]</div>[/if form_description] |
| 325 | 325 | BEFORE_HTML; |
| 326 | 326 | } else { |
| 327 | - $default_html = ''; |
|
| 328 | - } |
|
| 327 | + $default_html = ''; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - return $default_html; |
|
| 331 | - } |
|
| 330 | + return $default_html; |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - public static function get_draft_link() { |
|
| 334 | - $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
| 335 | - return $link; |
|
| 336 | - } |
|
| 333 | + public static function get_draft_link() { |
|
| 334 | + $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
| 335 | + return $link; |
|
| 336 | + } |
|
| 337 | 337 | |
| 338 | 338 | public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) { |
| 339 | 339 | $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values ); |
@@ -360,13 +360,13 @@ discard block |
||
| 360 | 360 | echo $button_parts[1]; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - /** |
|
| 364 | - * Automatically add end section fields if they don't exist (2.0 migration) |
|
| 365 | - * @since 2.0 |
|
| 366 | - * |
|
| 367 | - * @param boolean $reset_fields |
|
| 368 | - */ |
|
| 369 | - public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
| 363 | + /** |
|
| 364 | + * Automatically add end section fields if they don't exist (2.0 migration) |
|
| 365 | + * @since 2.0 |
|
| 366 | + * |
|
| 367 | + * @param boolean $reset_fields |
|
| 368 | + */ |
|
| 369 | + public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
| 370 | 370 | if ( empty( $fields ) ) { |
| 371 | 371 | return; |
| 372 | 372 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $prev_order = false; |
| 377 | 377 | $add_order = 0; |
| 378 | 378 | $last_field = false; |
| 379 | - foreach ( $fields as $field ) { |
|
| 379 | + foreach ( $fields as $field ) { |
|
| 380 | 380 | if ( $prev_order === $field->field_order ) { |
| 381 | 381 | $add_order++; |
| 382 | 382 | } |
@@ -387,48 +387,48 @@ discard block |
||
| 387 | 387 | FrmField::update( $field->id, array( 'field_order' => $field->field_order ) ); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - switch ( $field->type ) { |
|
| 391 | - case 'divider': |
|
| 392 | - // create an end section if open |
|
| 390 | + switch ( $field->type ) { |
|
| 391 | + case 'divider': |
|
| 392 | + // create an end section if open |
|
| 393 | 393 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
| 394 | 394 | |
| 395 | - // mark it open for the next end section |
|
| 396 | - $open = true; |
|
| 395 | + // mark it open for the next end section |
|
| 396 | + $open = true; |
|
| 397 | 397 | break; |
| 398 | - case 'break': |
|
| 398 | + case 'break': |
|
| 399 | 399 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
| 400 | 400 | break; |
| 401 | - case 'end_divider': |
|
| 402 | - if ( ! $open ) { |
|
| 403 | - // the section isn't open, so this is an extra field that needs to be removed |
|
| 404 | - FrmField::destroy( $field->id ); |
|
| 405 | - $reset_fields = true; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - // There is already an end section here, so there is no need to create one |
|
| 409 | - $open = false; |
|
| 410 | - } |
|
| 401 | + case 'end_divider': |
|
| 402 | + if ( ! $open ) { |
|
| 403 | + // the section isn't open, so this is an extra field that needs to be removed |
|
| 404 | + FrmField::destroy( $field->id ); |
|
| 405 | + $reset_fields = true; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + // There is already an end section here, so there is no need to create one |
|
| 409 | + $open = false; |
|
| 410 | + } |
|
| 411 | 411 | $prev_order = $field->field_order; |
| 412 | 412 | |
| 413 | 413 | $last_field = $field; |
| 414 | 414 | unset( $field ); |
| 415 | - } |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | 417 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field ); |
| 418 | - } |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | 420 | /** |
| 421 | 421 | * Create end section field if it doesn't exist. This is for migration from < 2.0 |
| 422 | 422 | * Fix any ordering that may be messed up |
| 423 | 423 | */ |
| 424 | 424 | public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) { |
| 425 | - if ( ! $open ) { |
|
| 426 | - return; |
|
| 427 | - } |
|
| 425 | + if ( ! $open ) { |
|
| 426 | + return; |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | 429 | $end_section_values['field_order'] = $field->field_order + 1; |
| 430 | 430 | |
| 431 | - FrmField::create( $end_section_values ); |
|
| 431 | + FrmField::create( $end_section_values ); |
|
| 432 | 432 | |
| 433 | 433 | if ( $move == 'move' ) { |
| 434 | 434 | // bump the order of current field unless we're at the end of the form |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | $add_order += 2; |
| 439 | - $open = false; |
|
| 440 | - $reset_fields = true; |
|
| 441 | - } |
|
| 439 | + $open = false; |
|
| 440 | + $reset_fields = true; |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | 443 | public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
| 444 | 444 | $codes = array( |
@@ -447,33 +447,33 @@ discard block |
||
| 447 | 447 | 'entry_key' => true, |
| 448 | 448 | ); |
| 449 | 449 | foreach ( $codes as $code => $show ) { |
| 450 | - if ( $code == 'form_name' ) { |
|
| 451 | - $replace_with = $form->name; |
|
| 452 | - } else if ( $code == 'form_description' ) { |
|
| 453 | - $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
| 454 | - } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
| 455 | - $replace_with = FrmAppHelper::simple_get( 'entry' ); |
|
| 456 | - } else { |
|
| 457 | - $replace_with = ''; |
|
| 458 | - } |
|
| 450 | + if ( $code == 'form_name' ) { |
|
| 451 | + $replace_with = $form->name; |
|
| 452 | + } else if ( $code == 'form_description' ) { |
|
| 453 | + $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
| 454 | + } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
| 455 | + $replace_with = FrmAppHelper::simple_get( 'entry' ); |
|
| 456 | + } else { |
|
| 457 | + $replace_with = ''; |
|
| 458 | + } |
|
| 459 | 459 | |
| 460 | 460 | FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html ); |
| 461 | - } |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - //replace [form_key] |
|
| 464 | - $html = str_replace('[form_key]', $form->form_key, $html); |
|
| 463 | + //replace [form_key] |
|
| 464 | + $html = str_replace('[form_key]', $form->form_key, $html); |
|
| 465 | 465 | |
| 466 | - //replace [frmurl] |
|
| 467 | - $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
| 466 | + //replace [frmurl] |
|
| 467 | + $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
| 468 | 468 | |
| 469 | 469 | if ( strpos( $html, '[button_label]' ) ) { |
| 470 | 470 | add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 ); |
| 471 | 471 | $submit_label = apply_filters( 'frm_submit_button', $title, $form ); |
| 472 | 472 | $submit_label = esc_attr( do_shortcode( $submit_label ) ); |
| 473 | 473 | $html = str_replace( '[button_label]', $submit_label, $html ); |
| 474 | - } |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
| 476 | + $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
| 477 | 477 | |
| 478 | 478 | if ( strpos( $html, '[if back_button]' ) ) { |
| 479 | 479 | $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html ); |
@@ -487,17 +487,17 @@ discard block |
||
| 487 | 487 | $html = do_shortcode( $html ); |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - return $html; |
|
| 491 | - } |
|
| 490 | + return $html; |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | 493 | public static function submit_button_label( $submit ) { |
| 494 | - if ( ! $submit || empty($submit) ) { |
|
| 495 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 496 | - $submit = $frm_settings->submit_value; |
|
| 497 | - } |
|
| 494 | + if ( ! $submit || empty($submit) ) { |
|
| 495 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 496 | + $submit = $frm_settings->submit_value; |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | - return $submit; |
|
| 500 | - } |
|
| 499 | + return $submit; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | 502 | /** |
| 503 | 503 | * If the Formidable styling isn't being loaded, |
@@ -514,19 +514,19 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | public static function get_form_style_class( $form = false ) { |
| 517 | - $style = self::get_form_style($form); |
|
| 518 | - $class = ' with_frm_style'; |
|
| 519 | - |
|
| 520 | - if ( empty($style) ) { |
|
| 521 | - if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
| 522 | - return $class; |
|
| 523 | - } else { |
|
| 524 | - return; |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - //If submit button needs to be inline or centered |
|
| 529 | - if ( is_object($form) ) { |
|
| 517 | + $style = self::get_form_style($form); |
|
| 518 | + $class = ' with_frm_style'; |
|
| 519 | + |
|
| 520 | + if ( empty($style) ) { |
|
| 521 | + if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
| 522 | + return $class; |
|
| 523 | + } else { |
|
| 524 | + return; |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + //If submit button needs to be inline or centered |
|
| 529 | + if ( is_object($form) ) { |
|
| 530 | 530 | $form = $form->options; |
| 531 | 531 | } |
| 532 | 532 | |
@@ -539,10 +539,10 @@ discard block |
||
| 539 | 539 | $class .= ' frm_center_submit'; |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
| 542 | + $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
| 543 | 543 | |
| 544 | - return $class; |
|
| 545 | - } |
|
| 544 | + return $class; |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | 547 | /** |
| 548 | 548 | * Returns appropriate class if form has top labels |
@@ -593,12 +593,12 @@ discard block |
||
| 593 | 593 | return in_array( $label_position, array( 'top', 'inside', 'hidden' ) ); |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - /** |
|
| 597 | - * @param string|boolean $form |
|
| 598 | - * |
|
| 599 | - * @return string |
|
| 600 | - */ |
|
| 601 | - public static function get_form_style( $form ) { |
|
| 596 | + /** |
|
| 597 | + * @param string|boolean $form |
|
| 598 | + * |
|
| 599 | + * @return string |
|
| 600 | + */ |
|
| 601 | + public static function get_form_style( $form ) { |
|
| 602 | 602 | $style = 1; |
| 603 | 603 | if ( empty( $form ) || 'default' == 'form' ) { |
| 604 | 604 | return $style; |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | $style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style; |
| 619 | 619 | |
| 620 | 620 | return $style; |
| 621 | - } |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | 623 | /** |
| 624 | 624 | * Display the validation error messages when an entry is submitted |
@@ -687,8 +687,8 @@ discard block |
||
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | public static function get_scroll_js( $form_id ) { |
| 690 | - echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>'; |
|
| 691 | - } |
|
| 690 | + echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>'; |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | 693 | /** |
| 694 | 694 | * @since 3.0 |
@@ -742,21 +742,21 @@ discard block |
||
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | public static function edit_form_link( $form_id ) { |
| 745 | - if ( is_object($form_id) ) { |
|
| 746 | - $form = $form_id; |
|
| 747 | - $name = $form->name; |
|
| 748 | - $form_id = $form->id; |
|
| 749 | - } else { |
|
| 750 | - $name = FrmForm::getName($form_id); |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - if ( $form_id ) { |
|
| 745 | + if ( is_object($form_id) ) { |
|
| 746 | + $form = $form_id; |
|
| 747 | + $name = $form->name; |
|
| 748 | + $form_id = $form->id; |
|
| 749 | + } else { |
|
| 750 | + $name = FrmForm::getName($form_id); |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + if ( $form_id ) { |
|
| 754 | 754 | $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>'; |
| 755 | - } else { |
|
| 756 | - $val = ''; |
|
| 757 | - } |
|
| 755 | + } else { |
|
| 756 | + $val = ''; |
|
| 757 | + } |
|
| 758 | 758 | |
| 759 | - return $val; |
|
| 759 | + return $val; |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | public static function delete_trash_link( $id, $status, $length = 'label' ) { |
@@ -937,18 +937,18 @@ discard block |
||
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | public static function status_nice_name( $status ) { |
| 940 | - $nice_names = array( |
|
| 941 | - 'draft' => __( 'Draft', 'formidable' ), |
|
| 942 | - 'trash' => __( 'Trash', 'formidable' ), |
|
| 943 | - 'publish' => __( 'Published', 'formidable' ), |
|
| 944 | - ); |
|
| 940 | + $nice_names = array( |
|
| 941 | + 'draft' => __( 'Draft', 'formidable' ), |
|
| 942 | + 'trash' => __( 'Trash', 'formidable' ), |
|
| 943 | + 'publish' => __( 'Published', 'formidable' ), |
|
| 944 | + ); |
|
| 945 | 945 | |
| 946 | - if ( ! in_array($status, array_keys($nice_names)) ) { |
|
| 947 | - $status = 'publish'; |
|
| 948 | - } |
|
| 946 | + if ( ! in_array($status, array_keys($nice_names)) ) { |
|
| 947 | + $status = 'publish'; |
|
| 948 | + } |
|
| 949 | 949 | |
| 950 | 950 | $name = $nice_names[ $status ]; |
| 951 | 951 | |
| 952 | - return $name; |
|
| 953 | - } |
|
| 952 | + return $name; |
|
| 953 | + } |
|
| 954 | 954 | } |