@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | class FrmAppController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - FrmAppHelper::maybe_add_permissions(); |
|
| 7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | - return; |
|
| 9 | - } |
|
| 6 | + FrmAppHelper::maybe_add_permissions(); |
|
| 7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', '', self::get_menu_position() ); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | private static function get_menu_position() { |
| 16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | return $pos; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public static function load_wp_admin_style() { |
|
| 23 | - FrmAppHelper::load_font_style(); |
|
| 24 | - } |
|
| 22 | + public static function load_wp_admin_style() { |
|
| 23 | + FrmAppHelper::load_font_style(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 27 | 27 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 28 | - if ( empty( $show_nav ) || ! $form ) { |
|
| 29 | - return; |
|
| 30 | - } |
|
| 28 | + if ( empty( $show_nav ) || ! $form ) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | FrmForm::maybe_get_form( $form ); |
| 33 | 33 | if ( ! is_object( $form ) ) { |
@@ -85,28 +85,28 @@ discard block |
||
| 85 | 85 | return $nav_items; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - // Adds a settings link to the plugins page |
|
| 89 | - public static function settings_link( $links ) { |
|
| 88 | + // Adds a settings link to the plugins page |
|
| 89 | + public static function settings_link( $links ) { |
|
| 90 | 90 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 91 | - array_unshift( $links, $settings ); |
|
| 91 | + array_unshift( $links, $settings ); |
|
| 92 | 92 | |
| 93 | - return $links; |
|
| 94 | - } |
|
| 93 | + return $links; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - public static function pro_get_started_headline() { |
|
| 96 | + public static function pro_get_started_headline() { |
|
| 97 | 97 | self::maybe_show_upgrade_bar(); |
| 98 | 98 | |
| 99 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 100 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 101 | - return; |
|
| 102 | - } |
|
| 99 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 100 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | if ( get_site_option( 'frmpro-authorized' ) && ! is_callable('load_formidable_pro') ) { |
| 105 | - FrmAppHelper::load_admin_wide_js(); |
|
| 105 | + FrmAppHelper::load_admin_wide_js(); |
|
| 106 | 106 | |
| 107 | - // user is authorized, but running free version |
|
| 108 | - $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/'; |
|
| 109 | - ?> |
|
| 107 | + // user is authorized, but running free version |
|
| 108 | + $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/'; |
|
| 109 | + ?> |
|
| 110 | 110 | <div class="error" class="frm_previous_install"> |
| 111 | 111 | <?php |
| 112 | 112 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | ) ); ?> |
| 119 | 119 | </div> |
| 120 | 120 | <?php |
| 121 | - } |
|
| 122 | - } |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | private static function maybe_show_upgrade_bar() { |
| 125 | 125 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - public static function admin_js() { |
|
| 227 | + public static function admin_js() { |
|
| 228 | 228 | $version = FrmAppHelper::plugin_version(); |
| 229 | 229 | FrmAppHelper::load_admin_wide_js( false ); |
| 230 | 230 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
| 236 | 236 | ), $version, true ); |
| 237 | 237 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 238 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 238 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 239 | 239 | wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version ); |
| 240 | 240 | |
| 241 | 241 | // load multselect js |
@@ -247,54 +247,54 @@ discard block |
||
| 247 | 247 | global $pagenow; |
| 248 | 248 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 249 | 249 | |
| 250 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 251 | - wp_enqueue_style( 'widgets' ); |
|
| 252 | - wp_enqueue_script( 'formidable' ); |
|
| 253 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 250 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 251 | + wp_enqueue_style( 'widgets' ); |
|
| 252 | + wp_enqueue_script( 'formidable' ); |
|
| 253 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 254 | 254 | FrmAppHelper::localize_script( 'admin' ); |
| 255 | 255 | |
| 256 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 256 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 257 | 257 | wp_enqueue_style( 'formidable-grids' ); |
| 258 | 258 | wp_enqueue_style( 'formidable-dropzone' ); |
| 259 | - add_thickbox(); |
|
| 259 | + add_thickbox(); |
|
| 260 | 260 | |
| 261 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 261 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 262 | 262 | |
| 263 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 264 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 265 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 263 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 264 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 265 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 266 | 266 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 267 | 267 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 268 | - if ( ! $post ) { |
|
| 269 | - return; |
|
| 270 | - } |
|
| 271 | - $post_type = $post->post_type; |
|
| 272 | - } else { |
|
| 273 | - return; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - if ( $post_type == 'frm_display' ) { |
|
| 277 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 278 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 279 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 268 | + if ( ! $post ) { |
|
| 269 | + return; |
|
| 270 | + } |
|
| 271 | + $post_type = $post->post_type; |
|
| 272 | + } else { |
|
| 273 | + return; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + if ( $post_type == 'frm_display' ) { |
|
| 277 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 278 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 279 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 280 | 280 | FrmAppHelper::localize_script( 'admin' ); |
| 281 | - } |
|
| 282 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 283 | - FrmAppHelper::load_admin_wide_js(); |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - public static function load_lang() { |
|
| 288 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Filter shortcodes in text widgets |
|
| 293 | - */ |
|
| 294 | - public static function widget_text_filter( $content ) { |
|
| 295 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 296 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 297 | - } |
|
| 281 | + } |
|
| 282 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 283 | + FrmAppHelper::load_admin_wide_js(); |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + public static function load_lang() { |
|
| 288 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Filter shortcodes in text widgets |
|
| 293 | + */ |
|
| 294 | + public static function widget_text_filter( $content ) { |
|
| 295 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 296 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | 299 | /** |
| 300 | 300 | * Deprecated in favor of wpmu_upgrade_site |
@@ -359,20 +359,20 @@ discard block |
||
| 359 | 359 | wp_die(); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - public static function activation_install() { |
|
| 363 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 364 | - FrmFormActionsController::actions_init(); |
|
| 365 | - self::install(); |
|
| 366 | - } |
|
| 362 | + public static function activation_install() { |
|
| 363 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 364 | + FrmFormActionsController::actions_init(); |
|
| 365 | + self::install(); |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - public static function install( $old_db_version = false ) { |
|
| 369 | - $frmdb = new FrmDb(); |
|
| 370 | - $frmdb->upgrade( $old_db_version ); |
|
| 371 | - } |
|
| 368 | + public static function install( $old_db_version = false ) { |
|
| 369 | + $frmdb = new FrmDb(); |
|
| 370 | + $frmdb->upgrade( $old_db_version ); |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - public static function uninstall() { |
|
| 373 | + public static function uninstall() { |
|
| 374 | 374 | FrmAppHelper::permission_check('administrator'); |
| 375 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 375 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 376 | 376 | |
| 377 | 377 | $frmdb = new FrmDb(); |
| 378 | 378 | $frmdb->uninstall(); |
@@ -381,43 +381,43 @@ discard block |
||
| 381 | 381 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 382 | 382 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 383 | 383 | |
| 384 | - wp_die(); |
|
| 385 | - } |
|
| 384 | + wp_die(); |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - public static function drop_tables( $tables ) { |
|
| 388 | - global $wpdb; |
|
| 389 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 390 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 391 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 392 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 393 | - return $tables; |
|
| 394 | - } |
|
| 387 | + public static function drop_tables( $tables ) { |
|
| 388 | + global $wpdb; |
|
| 389 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 390 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 391 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 392 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 393 | + return $tables; |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 397 | - public static function page_route( $content ) { |
|
| 398 | - global $post; |
|
| 396 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 397 | + public static function page_route( $content ) { |
|
| 398 | + global $post; |
|
| 399 | 399 | |
| 400 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 401 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 402 | - $content = FrmFormsController::page_preview(); |
|
| 403 | - } |
|
| 400 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 401 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 402 | + $content = FrmFormsController::page_preview(); |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | - return $content; |
|
| 406 | - } |
|
| 405 | + return $content; |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - public static function deauthorize() { |
|
| 408 | + public static function deauthorize() { |
|
| 409 | 409 | FrmAppHelper::permission_check('frm_change_settings'); |
| 410 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 411 | - |
|
| 412 | - delete_option( 'frmpro-credentials' ); |
|
| 413 | - delete_option( 'frmpro-authorized' ); |
|
| 414 | - delete_site_option( 'frmpro-credentials' ); |
|
| 415 | - delete_site_option( 'frmpro-authorized' ); |
|
| 416 | - wp_die(); |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - public static function get_form_shortcode( $atts ) { |
|
| 420 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 421 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 422 | - } |
|
| 410 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 411 | + |
|
| 412 | + delete_option( 'frmpro-credentials' ); |
|
| 413 | + delete_option( 'frmpro-authorized' ); |
|
| 414 | + delete_site_option( 'frmpro-credentials' ); |
|
| 415 | + delete_site_option( 'frmpro-authorized' ); |
|
| 416 | + wp_die(); |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + public static function get_form_shortcode( $atts ) { |
|
| 420 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 421 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 422 | + } |
|
| 423 | 423 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if ( get_site_option( 'frmpro-authorized' ) && ! is_callable('load_formidable_pro') ) { |
|
| 104 | + if ( get_site_option( 'frmpro-authorized' ) && ! is_callable( 'load_formidable_pro' ) ) { |
|
| 105 | 105 | FrmAppHelper::load_admin_wide_js(); |
| 106 | 106 | |
| 107 | 107 | // user is authorized, but running free version |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | <div class="update-nag frm-update-to-pro"> |
| 139 | 139 | <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> |
| 140 | 140 | <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> |
| 141 | - <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
| 141 | + <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
| 142 | 142 | </div> |
| 143 | 143 | <?php |
| 144 | 144 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | public static function uninstall() { |
| 374 | - FrmAppHelper::permission_check('administrator'); |
|
| 374 | + FrmAppHelper::permission_check( 'administrator' ); |
|
| 375 | 375 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 376 | 376 | |
| 377 | 377 | $frmdb = new FrmDb(); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | public static function deauthorize() { |
| 409 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 409 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 410 | 410 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 411 | 411 | |
| 412 | 412 | delete_option( 'frmpro-credentials' ); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | </div> |
| 6 | 6 | </div> |
| 7 | 7 | <?php |
| 8 | - return; |
|
| 8 | + return; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | global $frm_vars; |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // close open collapsible toggle div |
| 56 | 56 | if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) { |
| 57 | - echo "</div>\n"; |
|
| 58 | - unset($frm_vars['collapse_div']); |
|
| 57 | + echo "</div>\n"; |
|
| 58 | + unset($frm_vars['collapse_div']); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( empty($values) || ! isset($values['fields']) || empty($values['fields']) ) { ?> |
|
| 3 | -<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($form); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
| 2 | +if ( empty( $values ) || ! isset( $values['fields'] ) || empty( $values['fields'] ) ) { ?> |
|
| 3 | +<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $form ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
| 4 | 4 | <div class="frm_error_style"><strong><?php _e( 'Oops!', 'formidable' ) ?></strong> <?php printf( __( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), '<a href="' . esc_url( admin_url( '?page=formidable&frm_action=edit&id=' . $form->id ) ) . '">', '</a>' ) ?> |
| 5 | 5 | </div> |
| 6 | 6 | </div> |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>"> |
| 19 | 19 | <fieldset> |
| 20 | 20 | <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?> |
| 21 | -<?php do_action( 'frm_after_title', compact('form') ) ?> |
|
| 22 | -<input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" /> |
|
| 23 | -<input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" /> |
|
| 24 | -<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr($frm_hide_fields) ?>" /> |
|
| 25 | -<input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" /> |
|
| 21 | +<?php do_action( 'frm_after_title', compact( 'form' ) ) ?> |
|
| 22 | +<input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ) ?>" /> |
|
| 23 | +<input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ) ?>" /> |
|
| 24 | +<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr( $frm_hide_fields ) ?>" /> |
|
| 25 | +<input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ) ?>" /> |
|
| 26 | 26 | <input type="hidden" name="item_meta[0]" value="" /> |
| 27 | 27 | <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?> |
| 28 | -<input type="text" class="frm_hidden frm_verify" id="frm_verify_<?php echo esc_attr( $form->id ) ?>" name="frm_verify" value="<?php echo esc_attr( FrmAppHelper::get_param('frm_verify' ) ) ?>" <?php FrmFormsHelper::maybe_hide_inline() ?> /> |
|
| 28 | +<input type="text" class="frm_hidden frm_verify" id="frm_verify_<?php echo esc_attr( $form->id ) ?>" name="frm_verify" value="<?php echo esc_attr( FrmAppHelper::get_param( 'frm_verify' ) ) ?>" <?php FrmFormsHelper::maybe_hide_inline() ?> /> |
|
| 29 | 29 | |
| 30 | 30 | <?php if ( isset( $id ) ) { ?><input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /><?php } |
| 31 | 31 | |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | if ( FrmAppHelper::is_admin() ) { ?> |
| 38 | 38 | <div class="frm_form_field form-field"> |
| 39 | 39 | <label class="frm_primary_label"><?php _e( 'Entry Key', 'formidable' ) ?></label> |
| 40 | -<input type="text" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" /> |
|
| 40 | +<input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" /> |
|
| 41 | 41 | </div> |
| 42 | 42 | <?php } else { ?> |
| 43 | -<input type="hidden" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" /> |
|
| 43 | +<input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" /> |
|
| 44 | 44 | <?php } |
| 45 | 45 | |
| 46 | -do_action('frm_entry_form', $form, $form_action, $errors); |
|
| 46 | +do_action( 'frm_entry_form', $form, $form_action, $errors ); |
|
| 47 | 47 | |
| 48 | 48 | global $frm_vars; |
| 49 | 49 | // close open section div |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // close open collapsible toggle div |
| 56 | -if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) { |
|
| 56 | +if ( isset( $frm_vars['collapse_div'] ) && $frm_vars['collapse_div'] ) { |
|
| 57 | 57 | echo "</div>\n"; |
| 58 | - unset($frm_vars['collapse_div']); |
|
| 58 | + unset( $frm_vars['collapse_div'] ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form); |
|
| 61 | +echo FrmFormsHelper::replace_shortcodes( $values['after_html'], $form ); |
|
| 62 | 62 | |
| 63 | 63 | if ( FrmForm::show_submit( $form ) ) { |
| 64 | 64 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | </fieldset> |
| 72 | 72 | </div> |
| 73 | 73 | <?php |
| 74 | -if ( has_action('frm_entries_footer_scripts') ) { |
|
| 74 | +if ( has_action( 'frm_entries_footer_scripts' ) ) { |
|
| 75 | 75 | ?><script type="text/javascript"><?php |
| 76 | 76 | do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); |
| 77 | 77 | ?></script><?php |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | -<?php wp_nonce_field('frm_save_form_nonce', 'frm_save_form'); ?> |
|
| 1 | +<?php wp_nonce_field( 'frm_save_form_nonce', 'frm_save_form' ); ?> |
|
| 2 | 2 | <input type="hidden" name="status" value="<?php echo esc_attr( $values['status'] ); ?>" /> |
| 3 | 3 | <input type="hidden" name="new_status" value="" /> |
| 4 | 4 | |
| 5 | 5 | <div id="frm_form_editor_container"> |
| 6 | 6 | <div id="titlediv"> |
| 7 | - <input type="text" name="name" value="<?php echo esc_attr($form->name); ?>" id="title" placeholder="<?php esc_attr_e( 'Enter title here') ?>" /> |
|
| 7 | + <input type="text" name="name" value="<?php echo esc_attr( $form->name ); ?>" id="title" placeholder="<?php esc_attr_e( 'Enter title here' ) ?>" /> |
|
| 8 | 8 | <div id="edit-slug-box" class="hide-if-no-js"> |
| 9 | 9 | <div id="frm_form_key_box" class="alignright"> |
| 10 | 10 | <strong><?php _e( 'Form Key:', 'formidable' ) ?></strong> |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | </div> |
| 17 | 17 | |
| 18 | 18 | <div class="postbox"> |
| 19 | - <div class="frm_no_fields <?php echo ( isset($values['fields']) && ! empty($values['fields']) ) ? 'frm_hidden' : ''; ?>"> |
|
| 19 | + <div class="frm_no_fields <?php echo ( isset( $values['fields'] ) && ! empty( $values['fields'] ) ) ? 'frm_hidden' : ''; ?>"> |
|
| 20 | 20 | <div class="alignleft sketch1"> |
| 21 | 21 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/sketch_arrow1.png' ); ?>" alt="" /> |
| 22 | 22 | </div> |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | </div> |
| 51 | 51 | <ul id="new_fields" class="frm_sorting inside"> |
| 52 | 52 | <?php |
| 53 | -if ( isset($values['fields']) && ! empty($values['fields']) ) { |
|
| 53 | +if ( isset( $values['fields'] ) && ! empty( $values['fields'] ) ) { |
|
| 54 | 54 | $values['count'] = 0; |
| 55 | 55 | foreach ( $values['fields'] as $field ) { |
| 56 | - $values['count']++; |
|
| 56 | + $values['count'] ++; |
|
| 57 | 57 | FrmFieldsController::load_single_field( $field, $values ); |
| 58 | 58 | unset( $field ); |
| 59 | 59 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! isset( $values['doing_ajax'] ) ) { |
| 4 | - $li_classes .= ' ui-state-default widgets-holder-wrap'; ?> |
|
| 4 | + $li_classes .= ' ui-state-default widgets-holder-wrap'; ?> |
|
| 5 | 5 | <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?>" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo ( 'divider' == $field['type'] ) ? esc_attr( $field['form_select'] ) : esc_attr( $field['form_id'] ); ?>" data-ftype="<?php echo esc_attr( $display['type'] ) ?>"> |
| 6 | 6 | <?php |
| 7 | 7 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | </span> |
| 24 | 24 | <?php } |
| 25 | 25 | |
| 26 | - ?> |
|
| 26 | + ?> |
|
| 27 | 27 | <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
| 28 | 28 | |
| 29 | 29 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?> |
| 71 | 71 | <div class="frm-show-click frm_small_top_margin"><?php |
| 72 | 72 | |
| 73 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 73 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 74 | 74 | echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>'; |
| 75 | 75 | } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { |
| 76 | 76 | ?> |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | <a href="javascript:void(0);" id="other_button_<?php echo esc_attr( $field['id'] ); ?>" data-opttype="other" data-ftype="<?php echo esc_attr( $field['type'] ) ?>" class="button frm_cb_button frm_add_opt<?php echo ( in_array( $field['type'], array( 'radio', 'select' ) ) && $field['other'] == true ? ' frm_hidden' : '' ); ?>"><?php _e( 'Add "Other"', 'formidable' ) ?></a> |
| 83 | 83 | <input type="hidden" value="<?php echo esc_attr( $field['other'] ); ?>" id="other_input_<?php echo esc_attr( $field['id'] ); ?>" name="field_options[other_<?php echo esc_attr( $field['id'] ); ?>]"> |
| 84 | 84 | <?php |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
| 87 | + if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
| 88 | 88 | <a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ) ?>" title="<?php echo esc_attr( FrmAppHelper::truncate( strip_tags( str_replace( '"', '"', $field['name'] ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ) ); ?>" class="thickbox frm_orange"> |
| 89 | 89 | <?php _e( 'Bulk Edit Options', 'formidable' ) ?> |
| 90 | 90 | </a> |
| 91 | 91 | <?php } ?> |
| 92 | 92 | </div> |
| 93 | 93 | <?php |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | ?> |
| 96 | 96 | </div> |
| 97 | 97 | <?php |
@@ -126,31 +126,31 @@ discard block |
||
| 126 | 126 | <?php _e( 'Required', 'formidable' ) ?> |
| 127 | 127 | </label> |
| 128 | 128 | <?php |
| 129 | - } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | if ( $display['unique'] ) { |
| 132 | - if ( ! isset( $field['unique'] ) ) { |
|
| 133 | - $field['unique'] = false; |
|
| 134 | - } |
|
| 135 | - ?> |
|
| 132 | + if ( ! isset( $field['unique'] ) ) { |
|
| 133 | + $field['unique'] = false; |
|
| 134 | + } |
|
| 135 | + ?> |
|
| 136 | 136 | <label for="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Unique: Do not allow the same response multiple times. For example, if one user enters \'Joe\', then no one else will be allowed to enter the same name.', 'formidable' ) ?>"><input type="checkbox" name="field_options[unique_<?php echo esc_attr( $field['id'] ) ?>]" id="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" value="1" <?php checked( $field['unique'], 1 ); ?> class="frm_mark_unique" /> <?php _e( 'Unique', 'formidable' ) ?></label> |
| 137 | 137 | <?php |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | if ( $display['read_only'] ) { |
| 141 | - if ( ! isset( $field['read_only'] ) ) { |
|
| 142 | - $field['read_only'] = false; |
|
| 141 | + if ( ! isset( $field['read_only'] ) ) { |
|
| 142 | + $field['read_only'] = false; |
|
| 143 | 143 | } |
| 144 | - ?> |
|
| 144 | + ?> |
|
| 145 | 145 | <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ) ?>" > |
| 146 | 146 | <input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php checked( $field['read_only'], 1 ) ?>/> |
| 147 | 147 | <?php _e( 'Read Only', 'formidable' ) ?> |
| 148 | 148 | </label> |
| 149 | 149 | <?php } |
| 150 | 150 | |
| 151 | - do_action('frm_field_options_form_top', $field, $display, $values); |
|
| 151 | + do_action('frm_field_options_form_top', $field, $display, $values); |
|
| 152 | 152 | |
| 153 | - ?> |
|
| 153 | + ?> |
|
| 154 | 154 | <?php |
| 155 | 155 | if ( $display['required'] ) { ?> |
| 156 | 156 | <div class="frm_required_details<?php echo esc_attr( $field['id'] . ( $field['required'] ? '' : ' frm_hidden' ) ); ?>"> |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/html-content.php' ); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
|
| 254 | + if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
|
| 255 | 255 | <tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
| 256 | 256 | <td colspan="2"> |
| 257 | 257 | <div class="menu-settings"> |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | <input type="text" name="field_options[blank_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['blank'] ); ?>" /> |
| 265 | 265 | </p> |
| 266 | 266 | <?php |
| 267 | - } |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | if ( $display['invalid'] ) { ?> |
| 270 | 270 | <p><label><?php _e( 'Invalid Format', 'formidable' ) ?></label> |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | <input type="text" name="field_options[unique_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['unique_msg'] ); ?>" /> |
| 280 | 280 | </p> |
| 281 | 281 | <?php |
| 282 | - } |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | if ( $display['conf_field'] ) { ?> |
| 285 | 285 | <p class="frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>"> |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | <input type="text" name="field_options[conf_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_msg'] ); ?>" /> |
| 288 | 288 | </p> |
| 289 | 289 | <?php |
| 290 | - } ?> |
|
| 290 | + } ?> |
|
| 291 | 291 | </div> |
| 292 | 292 | </div> |
| 293 | 293 | </td> |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | <a href="javascript:void(0);" class="frm_bstooltip alignright frm-show-hover frm-move frm-hover-icon frm_icon_font frm_move_icon" title="<?php esc_attr_e( 'Move Field', 'formidable' ) ?>"> </a> |
| 16 | 16 | <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_delete_icon frm_delete_field" title="<?php esc_attr_e( 'Delete Field', 'formidable' ) ?>"> </a> |
| 17 | 17 | <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_duplicate_icon" title="<?php ( $field['type'] == 'divider' ) ? esc_attr_e( 'Duplicate Section', 'formidable' ) : esc_attr_e( 'Duplicate Field', 'formidable' ) ?>"> </a> |
| 18 | - <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr($field['id']) ?>" /> |
|
| 19 | - <?php do_action('frm_extra_field_actions', $field['id']); ?> |
|
| 18 | + <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr( $field['id'] ) ?>" /> |
|
| 19 | + <?php do_action( 'frm_extra_field_actions', $field['id'] ); ?> |
|
| 20 | 20 | <?php if ( $display['required'] ) { ?> |
| 21 | 21 | <span id="require_field_<?php echo esc_attr( $field['id'] ); ?>"> |
| 22 | 22 | <a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo FrmField::is_required( $field ) ? 'not ' : ''; ?>Required"></a> |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | <?php } |
| 25 | 25 | |
| 26 | 26 | ?> |
| 27 | - <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
|
| 27 | + <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button' : ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | <div id="field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_field_container"> |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | </div> |
| 43 | 43 | <?php |
| 44 | 44 | if ( $display['description'] ) { ?> |
| 45 | - <div class="frm_ipe_field_desc description <?php echo ($field['description'] == '') ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ($field['description'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div> |
|
| 45 | + <div class="frm_ipe_field_desc description <?php echo ( $field['description'] == '' ) ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['description'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div> |
|
| 46 | 46 | <input type="hidden" name="field_options[description_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['description'] ); ?>" /> |
| 47 | 47 | |
| 48 | 48 | <?php } ?> |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | <div class="frm_form_fields"> |
| 55 | 55 | <input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" class="dyn_default_value" /> |
| 56 | 56 | </div> |
| 57 | - <div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ($field['conf_desc'] == '') ? 'frm-show-click' : '' ?>"><?php |
|
| 58 | - echo ($field['conf_desc'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags($field['conf_desc']); ?></div> |
|
| 57 | + <div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ( $field['conf_desc'] == '' ) ? 'frm-show-click' : '' ?>"><?php |
|
| 58 | + echo ( $field['conf_desc'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['conf_desc'] ); ?></div> |
|
| 59 | 59 | <input type="hidden" name="field_options[conf_desc_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_desc'] ); ?>" /> |
| 60 | 60 | </div> |
| 61 | 61 | <?php if ( $display['clear_on_focus'] ) { ?> |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?> |
| 71 | 71 | <div class="frm-show-click frm_small_top_margin"><?php |
| 72 | 72 | |
| 73 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 73 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 74 | 74 | echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>'; |
| 75 | 75 | } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { |
| 76 | 76 | ?> |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | <?php |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
| 87 | + if ( ! isset( $field['post_field'] ) || $field['post_field'] != 'post_category' ) { ?> |
|
| 88 | 88 | <a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ) ?>" title="<?php echo esc_attr( FrmAppHelper::truncate( strip_tags( str_replace( '"', '"', $field['name'] ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ) ); ?>" class="thickbox frm_orange"> |
| 89 | 89 | <?php _e( 'Bulk Edit Options', 'formidable' ) ?> |
| 90 | 90 | </a> |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | <?php |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | -do_action('frm_before_field_options', $field); |
|
| 100 | +do_action( 'frm_before_field_options', $field ); |
|
| 101 | 101 | |
| 102 | 102 | if ( $display['options'] ) { ?> |
| 103 | 103 | <div class="widget"> |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | </div> |
| 108 | 108 | <div class="widget-inside"> |
| 109 | 109 | <table class="form-table frm_clear_none"> |
| 110 | - <?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?> |
|
| 110 | + <?php $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); ?> |
|
| 111 | 111 | <tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td> |
| 112 | 112 | <td> |
| 113 | - <select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
| 113 | + <select <?php if ( count( $field_types ) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
| 114 | 114 | <?php |
| 115 | 115 | foreach ( $field_types as $fkey => $ftype ) { ?> |
| 116 | - <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists($fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array($ftype) ? $ftype['name'] : $ftype ?> </option> |
|
| 116 | + <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists( $fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array( $ftype ) ? $ftype['name'] : $ftype ?> </option> |
|
| 117 | 117 | <?php |
| 118 | 118 | unset( $fkey, $ftype ); |
| 119 | 119 | } ?> |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | </label> |
| 149 | 149 | <?php } |
| 150 | 150 | |
| 151 | - do_action('frm_field_options_form_top', $field, $display, $values); |
|
| 151 | + do_action( 'frm_field_options_form_top', $field, $display, $values ); |
|
| 152 | 152 | |
| 153 | 153 | ?> |
| 154 | 154 | <?php |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | if ( $display['label_position'] ) { ?> |
| 186 | 186 | <tr><td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td> |
| 187 | 187 | <td><select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]"> |
| 188 | - <option value=""<?php selected($field['label'], ''); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 189 | - <option value="top"<?php selected($field['label'], 'top'); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
| 190 | - <option value="left"<?php selected($field['label'], 'left'); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
| 191 | - <option value="right"<?php selected($field['label'], 'right'); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
| 192 | - <option value="inline"<?php selected($field['label'], 'inline'); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
| 193 | - <option value="none"<?php selected($field['label'], 'none'); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
| 194 | - <option value="hidden"<?php selected($field['label'], 'hidden'); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
| 188 | + <option value=""<?php selected( $field['label'], '' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 189 | + <option value="top"<?php selected( $field['label'], 'top' ); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
| 190 | + <option value="left"<?php selected( $field['label'], 'left' ); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
| 191 | + <option value="right"<?php selected( $field['label'], 'right' ); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
| 192 | + <option value="inline"<?php selected( $field['label'], 'inline' ); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
| 193 | + <option value="none"<?php selected( $field['label'], 'none' ); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
| 194 | + <option value="hidden"<?php selected( $field['label'], 'hidden' ); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
| 195 | 195 | </select> |
| 196 | 196 | </td> |
| 197 | 197 | </tr> |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
| 255 | - <tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
|
| 255 | + <tr class="frm_validation_msg <?php echo ( $display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
|
| 256 | 256 | <td colspan="2"> |
| 257 | 257 | <div class="menu-settings"> |
| 258 | 258 | <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3> |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | <textarea name="field_options[description_<?php echo absint( $field['id'] ) ?>]" class="frm_98_width" rows="8"><?php |
| 4 | 4 | if ( FrmField::is_option_true( $field, 'stop_filter' ) ) { |
| 5 | 5 | echo $field['description']; |
| 6 | - } else{ |
|
| 6 | + } else { |
|
| 7 | 7 | echo FrmAppHelper::esc_textarea( $field['description'] ); |
| 8 | 8 | } |
| 9 | 9 | ?></textarea> |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | <textarea name="field_options[description_<?php echo absint( $field['id'] ) ?>]" class="frm_98_width" rows="8"><?php |
| 4 | 4 | if ( FrmField::is_option_true( $field, 'stop_filter' ) ) { |
| 5 | 5 | echo $field['description']; |
| 6 | - } else{ |
|
| 6 | + } else { |
|
| 7 | 7 | echo FrmAppHelper::esc_textarea( $field['description'] ); |
| 8 | 8 | } |
| 9 | 9 | ?></textarea> |
@@ -3,21 +3,21 @@ discard block |
||
| 3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
| 4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php |
| 5 | 5 | echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : ''; |
| 6 | - ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 6 | + ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 7 | 7 | |
| 8 | 8 | <?php |
| 9 | 9 | |
| 10 | 10 | } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 11 | - $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 11 | + $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 13 | 13 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 14 | - } else { |
|
| 15 | - do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 14 | + } else { |
|
| 15 | + do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 16 | 16 | <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>"> |
| 17 | 17 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?> |
| 18 | 18 | </ul> |
| 19 | 19 | <?php |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | } else if ( $field['type'] == 'select' ) { |
| 22 | 22 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/dropdown-field.php' ); |
| 23 | 23 | } else if ( in_array( $field['type'], array( 'html', 'user_id', 'hidden' ) ) ) { |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | if ( empty($frm_settings->pubkey) ) { ?> |
| 28 | 28 | <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div> |
| 29 | 29 | <?php |
| 30 | - } ?> |
|
| 30 | + } ?> |
|
| 31 | 31 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/> |
| 32 | 32 | <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" /> |
| 33 | 33 | <?php |
| 34 | 34 | } else { |
| 35 | - do_action( 'frm_display_added_fields', $field ); |
|
| 35 | + do_action( 'frm_display_added_fields', $field ); |
|
| 36 | 36 | do_action( 'frm_display_added_' . $field['type'] . '_field', $field ); |
| 37 | 37 | } |
@@ -3,17 +3,17 @@ discard block |
||
| 3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
| 4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php |
| 5 | 5 | echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : ''; |
| 6 | - ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 6 | + ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea( force_balance_tags( $field['default_value'] ) ); ?></textarea> |
|
| 7 | 7 | |
| 8 | 8 | <?php |
| 9 | 9 | |
| 10 | 10 | } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 11 | - $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 11 | + $field['default_value'] = maybe_unserialize( $field['default_value'] ); |
|
| 12 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 13 | 13 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 14 | 14 | } else { |
| 15 | - do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 16 | - <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 15 | + do_action( 'frm_add_multiple_opts_labels', $field ); ?> |
|
| 16 | + <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 17 | 17 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?> |
| 18 | 18 | </ul> |
| 19 | 19 | <?php |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | $type = str_replace( '_', '-', $field['type'] ); |
| 25 | 25 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/field-' . $type . '.php' ); |
| 26 | 26 | } else if ( $field['type'] == 'captcha' ) { |
| 27 | - if ( empty($frm_settings->pubkey) ) { ?> |
|
| 28 | - <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div> |
|
| 27 | + if ( empty( $frm_settings->pubkey ) ) { ?> |
|
| 28 | + <div class="howto frm_no_captcha_text"><?php printf( __( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>' ) ?></div> |
|
| 29 | 29 | <?php |
| 30 | 30 | } ?> |
| 31 | 31 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/> |
@@ -10,41 +10,41 @@ discard block |
||
| 10 | 10 | <?php |
| 11 | 11 | |
| 12 | 12 | } else if ( $field['type'] == 'radio' ) { |
| 13 | - $read_only = false; |
|
| 13 | + $read_only = false; |
|
| 14 | 14 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
| 15 | - $read_only = true; ?> |
|
| 15 | + $read_only = true; ?> |
|
| 16 | 16 | <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" /> |
| 17 | 17 | <?php |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 20 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 21 | 21 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 22 | - } else if ( is_array($field['options']) ) { |
|
| 23 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 22 | + } else if ( is_array($field['options']) ) { |
|
| 23 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 24 | 24 | if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] !== $opt_key ) ) { |
| 25 | - continue; |
|
| 26 | - } |
|
| 25 | + continue; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 29 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
| 28 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 29 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
| 30 | 30 | <div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php |
| 31 | 31 | |
| 32 | 32 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 33 | 33 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
| 34 | - } |
|
| 35 | - $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
| 34 | + } |
|
| 35 | + $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
| 36 | 36 | |
| 37 | - $other_opt = false; |
|
| 38 | - $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
|
| 39 | - ?> |
|
| 37 | + $other_opt = false; |
|
| 38 | + $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
|
| 39 | + ?> |
|
| 40 | 40 | <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php |
| 41 | - echo $checked; |
|
| 42 | - do_action('frm_field_input_html', $field); |
|
| 41 | + echo $checked; |
|
| 42 | + do_action('frm_field_input_html', $field); |
|
| 43 | 43 | ?>/><?php |
| 44 | 44 | |
| 45 | 45 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 46 | 46 | echo ' ' . $opt . '</label>'; |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | FrmFieldsHelper::include_other_input( array( |
| 50 | 50 | 'other_opt' => $other_opt, 'read_only' => $read_only, |
@@ -53,58 +53,58 @@ discard block |
||
| 53 | 53 | 'html_id' => $html_id, 'opt_key' => $opt_key, |
| 54 | 54 | ) ); |
| 55 | 55 | |
| 56 | - unset( $other_opt, $other_args ); |
|
| 56 | + unset( $other_opt, $other_args ); |
|
| 57 | 57 | ?></div> |
| 58 | 58 | <?php |
| 59 | - } |
|
| 60 | - } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | } else if ( $field['type'] == 'select' ) { |
| 62 | 62 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/dropdown-field.php' ); |
| 63 | 63 | } else if ( $field['type'] == 'checkbox' ) { |
| 64 | - $checked_values = $field['value']; |
|
| 65 | - $read_only = false; |
|
| 64 | + $checked_values = $field['value']; |
|
| 65 | + $read_only = false; |
|
| 66 | 66 | |
| 67 | 67 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
| 68 | - $read_only = true; |
|
| 69 | - if ( $checked_values ) { |
|
| 70 | - foreach ( (array) $checked_values as $checked_value ) { ?> |
|
| 68 | + $read_only = true; |
|
| 69 | + if ( $checked_values ) { |
|
| 70 | + foreach ( (array) $checked_values as $checked_value ) { ?> |
|
| 71 | 71 | <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> |
| 72 | 72 | <?php |
| 73 | - } |
|
| 74 | - } else { ?> |
|
| 73 | + } |
|
| 74 | + } else { ?> |
|
| 75 | 75 | <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" /> |
| 76 | 76 | <?php |
| 77 | - } |
|
| 78 | - } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 80 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 81 | 81 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 82 | - } else if ( $field['options'] ) { |
|
| 83 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 84 | - if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] !== $opt_key) ) { |
|
| 85 | - continue; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 89 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 90 | - $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 91 | - |
|
| 92 | - // Check if other opt, and get values for other field if needed |
|
| 93 | - $other_opt = false; |
|
| 82 | + } else if ( $field['options'] ) { |
|
| 83 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 84 | + if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] !== $opt_key) ) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 89 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 90 | + $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 91 | + |
|
| 92 | + // Check if other opt, and get values for other field if needed |
|
| 93 | + $other_opt = false; |
|
| 94 | 94 | $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked ); |
| 95 | 95 | |
| 96 | - ?> |
|
| 96 | + ?> |
|
| 97 | 97 | <div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="<?php echo esc_attr( FrmFieldsHelper::get_checkbox_id( $field, $opt_key ) ) ?>"><?php |
| 98 | 98 | |
| 99 | - if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 100 | - ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
|
| 101 | - } |
|
| 99 | + if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 100 | + ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
| 103 | + ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
| 104 | 104 | |
| 105 | - if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 105 | + if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 106 | 106 | echo ' ' . $opt . '</label>'; |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | FrmFieldsHelper::include_other_input( array( |
| 110 | 110 | 'other_opt' => $other_opt, 'read_only' => $read_only, |
@@ -113,21 +113,21 @@ discard block |
||
| 113 | 113 | 'html_id' => $html_id, 'opt_key' => $opt_key, |
| 114 | 114 | ) ); |
| 115 | 115 | |
| 116 | - unset( $other_opt, $other_args, $checked ); |
|
| 116 | + unset( $other_opt, $other_args, $checked ); |
|
| 117 | 117 | |
| 118 | - ?></div> |
|
| 118 | + ?></div> |
|
| 119 | 119 | <?php |
| 120 | - } |
|
| 121 | - } |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | 122 | } else if ( $field['type'] == 'phone' ) { |
| 123 | 123 | ?> |
| 124 | 124 | <input type="<?php echo ( $frm_settings->use_html ) ? 'tel' : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/> |
| 125 | 125 | <?php |
| 126 | 126 | } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) { |
| 127 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 128 | - if ( ! empty($frm_settings->pubkey) ) { |
|
| 129 | - FrmFieldsHelper::display_recaptcha($field); |
|
| 130 | - } |
|
| 127 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 128 | + if ( ! empty($frm_settings->pubkey) ) { |
|
| 129 | + FrmFieldsHelper::display_recaptcha($field); |
|
| 130 | + } |
|
| 131 | 131 | } else { |
| 132 | 132 | do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) ); |
| 133 | 133 | do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) ); |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php if ( in_array( $field['type'], array( 'email', 'url', 'text', 'number' ) ) ) { ?> |
| 2 | -<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/> |
|
| 2 | +<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/> |
|
| 3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
| 4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php |
| 5 | 5 | if ( $field['max'] ) { |
| 6 | 6 | echo 'rows="' . esc_attr( $field['max'] ) . '" '; |
| 7 | 7 | } |
| 8 | -do_action('frm_field_input_html', $field); |
|
| 9 | -?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea> |
|
| 8 | +do_action( 'frm_field_input_html', $field ); |
|
| 9 | +?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea> |
|
| 10 | 10 | <?php |
| 11 | 11 | |
| 12 | 12 | } else if ( $field['type'] == 'radio' ) { |
@@ -17,29 +17,29 @@ discard block |
||
| 17 | 17 | <?php |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 20 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 21 | 21 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 22 | - } else if ( is_array($field['options']) ) { |
|
| 22 | + } else if ( is_array( $field['options'] ) ) { |
|
| 23 | 23 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 24 | 24 | if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] !== $opt_key ) ) { |
| 25 | 25 | continue; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 29 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
| 28 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 29 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?> |
|
| 30 | 30 | <div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php |
| 31 | 31 | |
| 32 | 32 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 33 | 33 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
| 34 | 34 | } |
| 35 | - $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
| 35 | + $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' '; |
|
| 36 | 36 | |
| 37 | 37 | $other_opt = false; |
| 38 | 38 | $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
| 39 | 39 | ?> |
| 40 | 40 | <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php |
| 41 | 41 | echo $checked; |
| 42 | - do_action('frm_field_input_html', $field); |
|
| 42 | + do_action( 'frm_field_input_html', $field ); |
|
| 43 | 43 | ?>/><?php |
| 44 | 44 | |
| 45 | 45 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
@@ -77,17 +77,17 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 80 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 81 | 81 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 82 | 82 | } else if ( $field['options'] ) { |
| 83 | 83 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 84 | - if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] !== $opt_key) ) { |
|
| 84 | + if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] !== $opt_key ) ) { |
|
| 85 | 85 | continue; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 89 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 90 | - $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 88 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 89 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 90 | + $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Check if other opt, and get values for other field if needed |
| 93 | 93 | $other_opt = false; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
| 103 | + ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php |
|
| 104 | 104 | |
| 105 | 105 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 106 | 106 | echo ' ' . $opt . '</label>'; |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | <?php |
| 126 | 126 | } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) { |
| 127 | 127 | $frm_settings = FrmAppHelper::get_settings(); |
| 128 | - if ( ! empty($frm_settings->pubkey) ) { |
|
| 129 | - FrmFieldsHelper::display_recaptcha($field); |
|
| 128 | + if ( ! empty( $frm_settings->pubkey ) ) { |
|
| 129 | + FrmFieldsHelper::display_recaptcha( $field ); |
|
| 130 | 130 | } |
| 131 | 131 | } else { |
| 132 | 132 | do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) ); |
@@ -5,69 +5,69 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class FrmEntriesHelper { |
| 7 | 7 | |
| 8 | - public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
| 9 | - $values = array(); |
|
| 8 | + public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
| 9 | + $values = array(); |
|
| 10 | 10 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
| 11 | 11 | $values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' ); |
| 12 | - } |
|
| 13 | - |
|
| 14 | - $values['fields'] = array(); |
|
| 15 | - if ( empty($fields) ) { |
|
| 16 | - return apply_filters('frm_setup_new_entry', $values); |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - foreach ( (array) $fields as $field ) { |
|
| 20 | - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
| 21 | - |
|
| 22 | - $field_array = array( |
|
| 23 | - 'id' => $field->id, |
|
| 24 | - 'value' => $new_value, |
|
| 25 | - 'default_value' => $field->default_value, |
|
| 26 | - 'name' => $field->name, |
|
| 27 | - 'description' => $field->description, |
|
| 28 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 29 | - 'options' => $field->options, |
|
| 30 | - 'required' => $field->required, |
|
| 31 | - 'field_key' => $field->field_key, |
|
| 32 | - 'field_order' => $field->field_order, |
|
| 33 | - 'form_id' => $field->form_id, |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + $values['fields'] = array(); |
|
| 15 | + if ( empty($fields) ) { |
|
| 16 | + return apply_filters('frm_setup_new_entry', $values); |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + foreach ( (array) $fields as $field ) { |
|
| 20 | + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
| 21 | + |
|
| 22 | + $field_array = array( |
|
| 23 | + 'id' => $field->id, |
|
| 24 | + 'value' => $new_value, |
|
| 25 | + 'default_value' => $field->default_value, |
|
| 26 | + 'name' => $field->name, |
|
| 27 | + 'description' => $field->description, |
|
| 28 | + 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 29 | + 'options' => $field->options, |
|
| 30 | + 'required' => $field->required, |
|
| 31 | + 'field_key' => $field->field_key, |
|
| 32 | + 'field_order' => $field->field_order, |
|
| 33 | + 'form_id' => $field->form_id, |
|
| 34 | 34 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
| 35 | - 'reset_value' => $reset, |
|
| 35 | + 'reset_value' => $reset, |
|
| 36 | 36 | 'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0', |
| 37 | - ); |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | 39 | $opt_defaults = FrmFieldsHelper::get_default_field_options( $field_array['type'] ); |
| 40 | - $opt_defaults['required_indicator'] = ''; |
|
| 40 | + $opt_defaults['required_indicator'] = ''; |
|
| 41 | 41 | $opt_defaults['original_type'] = $field->type; |
| 42 | 42 | |
| 43 | 43 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 44 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 45 | - unset($opt, $default_opt); |
|
| 46 | - } |
|
| 44 | + $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 45 | + unset($opt, $default_opt); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - unset($opt_defaults); |
|
| 48 | + unset($opt_defaults); |
|
| 49 | 49 | |
| 50 | - if ( $field_array['custom_html'] == '' ) { |
|
| 51 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 52 | - } |
|
| 50 | + if ( $field_array['custom_html'] == '' ) { |
|
| 51 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 55 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 54 | + $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 55 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 56 | 56 | |
| 57 | - $values['fields'][] = $field_array; |
|
| 57 | + $values['fields'][] = $field_array; |
|
| 58 | 58 | |
| 59 | - if ( ! $form || ! isset($form->id) ) { |
|
| 60 | - $form = FrmForm::getOne($field->form_id); |
|
| 61 | - } |
|
| 62 | - } |
|
| 59 | + if ( ! $form || ! isset($form->id) ) { |
|
| 60 | + $form = FrmForm::getOne($field->form_id); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $form->options = maybe_unserialize($form->options); |
|
| 65 | - if ( is_array($form->options) ) { |
|
| 66 | - foreach ( $form->options as $opt => $value ) { |
|
| 67 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
| 68 | - unset($opt, $value); |
|
| 69 | - } |
|
| 70 | - } |
|
| 64 | + $form->options = maybe_unserialize($form->options); |
|
| 65 | + if ( is_array($form->options) ) { |
|
| 66 | + foreach ( $form->options as $opt => $value ) { |
|
| 67 | + $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
| 68 | + unset($opt, $value); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 73 | 73 | |
@@ -77,19 +77,19 @@ discard block |
||
| 77 | 77 | $values = array_merge( $form_defaults, $values ); |
| 78 | 78 | |
| 79 | 79 | return apply_filters( 'frm_setup_new_entry', $values ); |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * Set the value for each field |
|
| 84 | - * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
| 85 | - * |
|
| 86 | - * @since 2.0.13 |
|
| 87 | - * |
|
| 88 | - * @param object $field - this is passed by reference since it is an object |
|
| 89 | - * @param boolean $reset |
|
| 90 | - * @param array $args |
|
| 91 | - * @return string|array $new_value |
|
| 92 | - */ |
|
| 83 | + * Set the value for each field |
|
| 84 | + * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
| 85 | + * |
|
| 86 | + * @since 2.0.13 |
|
| 87 | + * |
|
| 88 | + * @param object $field - this is passed by reference since it is an object |
|
| 89 | + * @param boolean $reset |
|
| 90 | + * @param array $args |
|
| 91 | + * @return string|array $new_value |
|
| 92 | + */ |
|
| 93 | 93 | private static function get_field_value_for_new_entry( $field, $reset, $args ) { |
| 94 | 94 | //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array |
| 95 | 95 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * Check if a field has a posted value |
|
| 125 | - * |
|
| 126 | - * @since 2.01.0 |
|
| 127 | - * @param object $field |
|
| 128 | - * @param array $args |
|
| 129 | - * @return boolean $value_is_posted |
|
| 130 | - */ |
|
| 124 | + * Check if a field has a posted value |
|
| 125 | + * |
|
| 126 | + * @since 2.01.0 |
|
| 127 | + * @param object $field |
|
| 128 | + * @param array $args |
|
| 129 | + * @return boolean $value_is_posted |
|
| 130 | + */ |
|
| 131 | 131 | public static function value_is_posted( $field, $args ) { |
| 132 | 132 | $value_is_posted = false; |
| 133 | 133 | if ( $_POST ) { |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | public static function setup_edit_vars( $values, $record ) { |
| 147 | 147 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
| 148 | - $values['form_id'] = $record->form_id; |
|
| 149 | - $values['is_draft'] = $record->is_draft; |
|
| 150 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 151 | - } |
|
| 148 | + $values['form_id'] = $record->form_id; |
|
| 149 | + $values['is_draft'] = $record->is_draft; |
|
| 150 | + return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - public static function get_admin_params( $form = null ) { |
|
| 153 | + public static function get_admin_params( $form = null ) { |
|
| 154 | 154 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' ); |
| 155 | 155 | return FrmForm::set_current_form( $form ); |
| 156 | - } |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | public static function set_current_form( $form_id ) { |
| 159 | 159 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' ); |
@@ -165,284 +165,284 @@ discard block |
||
| 165 | 165 | return FrmForm::get_current_form( $form_id ); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - public static function get_current_form_id() { |
|
| 168 | + public static function get_current_form_id() { |
|
| 169 | 169 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' ); |
| 170 | 170 | return FrmForm::get_current_form_id(); |
| 171 | - } |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - public static function maybe_get_entry( &$entry ) { |
|
| 173 | + public static function maybe_get_entry( &$entry ) { |
|
| 174 | 174 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' ); |
| 175 | 175 | FrmEntry::maybe_get_entry( $entry ); |
| 176 | - } |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | 178 | public static function replace_default_message( $message, $atts ) { |
| 179 | - if ( strpos($message, '[default-message') === false && |
|
| 180 | - strpos($message, '[default_message') === false && |
|
| 181 | - ! empty( $message ) ) { |
|
| 182 | - return $message; |
|
| 183 | - } |
|
| 179 | + if ( strpos($message, '[default-message') === false && |
|
| 180 | + strpos($message, '[default_message') === false && |
|
| 181 | + ! empty( $message ) ) { |
|
| 182 | + return $message; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - if ( empty($message) ) { |
|
| 186 | - $message = '[default-message]'; |
|
| 187 | - } |
|
| 185 | + if ( empty($message) ) { |
|
| 186 | + $message = '[default-message]'; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 189 | + preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 190 | 190 | |
| 191 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 191 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 192 | 192 | $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
| 193 | 193 | if ( ! empty( $add_atts ) ) { |
| 194 | - $this_atts = array_merge($atts, $add_atts); |
|
| 195 | - } else { |
|
| 196 | - $this_atts = $atts; |
|
| 197 | - } |
|
| 194 | + $this_atts = array_merge($atts, $add_atts); |
|
| 195 | + } else { |
|
| 196 | + $this_atts = $atts; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | 199 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
| 200 | 200 | |
| 201 | - // Add the default message |
|
| 202 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 203 | - } |
|
| 201 | + // Add the default message |
|
| 202 | + $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - return $message; |
|
| 206 | - } |
|
| 205 | + return $message; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 209 | 209 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
| 210 | 210 | |
| 211 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 211 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 212 | 212 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 216 | - return self::display_value($field_value, $field, $atts); |
|
| 217 | - } |
|
| 215 | + if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 216 | + return self::display_value($field_value, $field, $atts); |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - // this is an embeded form |
|
| 220 | - $val = ''; |
|
| 219 | + // this is an embeded form |
|
| 220 | + $val = ''; |
|
| 221 | 221 | |
| 222 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 223 | - //this is a repeating section |
|
| 222 | + if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 223 | + //this is a repeating section |
|
| 224 | 224 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
| 225 | - } else { |
|
| 226 | - // get all values for this field |
|
| 227 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 225 | + } else { |
|
| 226 | + // get all values for this field |
|
| 227 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 228 | 228 | |
| 229 | - if ( $child_values ) { |
|
| 230 | - $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
| 231 | - } |
|
| 232 | - } |
|
| 229 | + if ( $child_values ) { |
|
| 230 | + $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - $field_value = array(); |
|
| 234 | + $field_value = array(); |
|
| 235 | 235 | |
| 236 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 237 | - return $val; |
|
| 238 | - } |
|
| 236 | + if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 237 | + return $val; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - foreach ( $child_entries as $child_entry ) { |
|
| 241 | - $atts['item_id'] = $child_entry->id; |
|
| 242 | - $atts['post_id'] = $child_entry->post_id; |
|
| 240 | + foreach ( $child_entries as $child_entry ) { |
|
| 241 | + $atts['item_id'] = $child_entry->id; |
|
| 242 | + $atts['post_id'] = $child_entry->post_id; |
|
| 243 | 243 | |
| 244 | - // get the value for this field -- check for post values as well |
|
| 245 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 244 | + // get the value for this field -- check for post values as well |
|
| 245 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 246 | 246 | |
| 247 | - if ( $entry_val ) { |
|
| 248 | - // foreach entry get display_value |
|
| 249 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 250 | - } |
|
| 247 | + if ( $entry_val ) { |
|
| 248 | + // foreach entry get display_value |
|
| 249 | + $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - unset($child_entry); |
|
| 253 | - } |
|
| 252 | + unset($child_entry); |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - $val = implode(', ', (array) $field_value ); |
|
| 255 | + $val = implode(', ', (array) $field_value ); |
|
| 256 | 256 | $val = wp_kses_post( $val ); |
| 257 | 257 | |
| 258 | - return $val; |
|
| 259 | - } |
|
| 258 | + return $val; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * Prepare the saved value for display |
|
| 263 | - * @return string |
|
| 264 | - */ |
|
| 261 | + /** |
|
| 262 | + * Prepare the saved value for display |
|
| 263 | + * @return string |
|
| 264 | + */ |
|
| 265 | 265 | public static function display_value( $value, $field, $atts = array() ) { |
| 266 | 266 | |
| 267 | - $defaults = array( |
|
| 268 | - 'type' => '', 'html' => false, 'show_filename' => true, |
|
| 269 | - 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
| 270 | - 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
| 267 | + $defaults = array( |
|
| 268 | + 'type' => '', 'html' => false, 'show_filename' => true, |
|
| 269 | + 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
| 270 | + 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
| 271 | 271 | 'return_array' => false, |
| 272 | - ); |
|
| 272 | + ); |
|
| 273 | 273 | |
| 274 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 275 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 274 | + $atts = wp_parse_args( $atts, $defaults ); |
|
| 275 | + $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 276 | 276 | |
| 277 | - if ( ! isset($field->field_options['post_field']) ) { |
|
| 278 | - $field->field_options['post_field'] = ''; |
|
| 279 | - } |
|
| 277 | + if ( ! isset($field->field_options['post_field']) ) { |
|
| 278 | + $field->field_options['post_field'] = ''; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 282 | - $field->field_options['custom_field'] = ''; |
|
| 283 | - } |
|
| 281 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 282 | + $field->field_options['custom_field'] = ''; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
| 286 | - $atts['pre_truncate'] = $atts['truncate']; |
|
| 287 | - $atts['truncate'] = true; |
|
| 288 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 285 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
| 286 | + $atts['pre_truncate'] = $atts['truncate']; |
|
| 287 | + $atts['truncate'] = true; |
|
| 288 | + $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 289 | 289 | |
| 290 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 291 | - $atts['truncate'] = $atts['pre_truncate']; |
|
| 292 | - } |
|
| 290 | + $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 291 | + $atts['truncate'] = $atts['pre_truncate']; |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - if ( $value == '' ) { |
|
| 295 | - return $value; |
|
| 296 | - } |
|
| 294 | + if ( $value == '' ) { |
|
| 295 | + return $value; |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 298 | + $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 299 | 299 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
| 300 | 300 | |
| 301 | - $new_value = ''; |
|
| 301 | + $new_value = ''; |
|
| 302 | 302 | |
| 303 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 304 | - foreach ( $value as $val ) { |
|
| 305 | - if ( is_array($val) ) { |
|
| 303 | + if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 304 | + foreach ( $value as $val ) { |
|
| 305 | + if ( is_array($val) ) { |
|
| 306 | 306 | //TODO: add options for display (li or ,) |
| 307 | - $new_value .= implode($atts['sep'], $val); |
|
| 308 | - if ( $atts['type'] != 'data' ) { |
|
| 309 | - $new_value .= '<br/>'; |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - unset($val); |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - if ( ! empty($new_value) ) { |
|
| 317 | - $value = $new_value; |
|
| 318 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 319 | - $value = implode($atts['sep'], $value); |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
| 323 | - $value = FrmAppHelper::truncate($value, 50); |
|
| 324 | - } |
|
| 307 | + $new_value .= implode($atts['sep'], $val); |
|
| 308 | + if ( $atts['type'] != 'data' ) { |
|
| 309 | + $new_value .= '<br/>'; |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + unset($val); |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + if ( ! empty($new_value) ) { |
|
| 317 | + $value = $new_value; |
|
| 318 | + } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 319 | + $value = implode($atts['sep'], $value); |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
| 323 | + $value = FrmAppHelper::truncate($value, 50); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | 326 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
| 327 | 327 | $value = wp_kses_post( $value ); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 331 | - } |
|
| 330 | + return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | 333 | public static function set_posted_value( $field, $value, $args ) { |
| 334 | - // If validating a field with "other" opt, set back to prev value now |
|
| 335 | - if ( isset( $args['other'] ) && $args['other'] ) { |
|
| 336 | - $value = $args['temp_value']; |
|
| 337 | - } |
|
| 338 | - if ( empty($args['parent_field_id']) ) { |
|
| 339 | - $_POST['item_meta'][ $field->id ] = $value; |
|
| 340 | - } else { |
|
| 341 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 342 | - } |
|
| 343 | - } |
|
| 334 | + // If validating a field with "other" opt, set back to prev value now |
|
| 335 | + if ( isset( $args['other'] ) && $args['other'] ) { |
|
| 336 | + $value = $args['temp_value']; |
|
| 337 | + } |
|
| 338 | + if ( empty($args['parent_field_id']) ) { |
|
| 339 | + $_POST['item_meta'][ $field->id ] = $value; |
|
| 340 | + } else { |
|
| 341 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | public static function get_posted_value( $field, &$value, $args ) { |
| 346 | 346 | $field_id = is_object( $field ) ? $field->id : $field; |
| 347 | 347 | |
| 348 | - if ( empty($args['parent_field_id']) ) { |
|
| 349 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 350 | - } else { |
|
| 351 | - $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 ] : ''; |
|
| 352 | - } |
|
| 348 | + if ( empty($args['parent_field_id']) ) { |
|
| 349 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 350 | + } else { |
|
| 351 | + $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 ] : ''; |
|
| 352 | + } |
|
| 353 | 353 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 354 | 354 | $value = stripslashes_deep( $value ); |
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * Check if field has an "Other" option and if any other values are posted |
|
| 359 | - * |
|
| 360 | - * @since 2.0 |
|
| 361 | - * |
|
| 362 | - * @param object $field |
|
| 363 | - * @param string|array $value |
|
| 364 | - * @param array $args |
|
| 365 | - */ |
|
| 366 | - public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
| 367 | - $args['other'] = false; |
|
| 368 | - if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
| 369 | - return; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - // Get other value for fields in repeating section |
|
| 373 | - self::set_other_repeating_vals( $field, $value, $args ); |
|
| 374 | - |
|
| 375 | - // Check if there are any posted "Other" values |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * Check if field has an "Other" option and if any other values are posted |
|
| 359 | + * |
|
| 360 | + * @since 2.0 |
|
| 361 | + * |
|
| 362 | + * @param object $field |
|
| 363 | + * @param string|array $value |
|
| 364 | + * @param array $args |
|
| 365 | + */ |
|
| 366 | + public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
| 367 | + $args['other'] = false; |
|
| 368 | + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
| 369 | + return; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + // Get other value for fields in repeating section |
|
| 373 | + self::set_other_repeating_vals( $field, $value, $args ); |
|
| 374 | + |
|
| 375 | + // Check if there are any posted "Other" values |
|
| 376 | 376 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
| 377 | 377 | |
| 378 | - // Save original value |
|
| 379 | - $args['temp_value'] = $value; |
|
| 380 | - $args['other'] = true; |
|
| 381 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 382 | - |
|
| 383 | - // Set the validation value now |
|
| 384 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
| 390 | - * |
|
| 391 | - * @since 2.0 |
|
| 392 | - * |
|
| 393 | - * @param object $field |
|
| 394 | - * @param string|array $value |
|
| 395 | - * @param array $args |
|
| 396 | - */ |
|
| 397 | - public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
| 398 | - if ( ! $args['parent_field_id'] ) { |
|
| 399 | - return; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - // Check if there are any other posted "other" values for this field |
|
| 378 | + // Save original value |
|
| 379 | + $args['temp_value'] = $value; |
|
| 380 | + $args['other'] = true; |
|
| 381 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 382 | + |
|
| 383 | + // Set the validation value now |
|
| 384 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
| 390 | + * |
|
| 391 | + * @since 2.0 |
|
| 392 | + * |
|
| 393 | + * @param object $field |
|
| 394 | + * @param string|array $value |
|
| 395 | + * @param array $args |
|
| 396 | + */ |
|
| 397 | + public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
| 398 | + if ( ! $args['parent_field_id'] ) { |
|
| 399 | + return; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + // Check if there are any other posted "other" values for this field |
|
| 403 | 403 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
| 404 | - // Save original value |
|
| 405 | - $args['temp_value'] = $value; |
|
| 406 | - $args['other'] = true; |
|
| 407 | - |
|
| 408 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 409 | - |
|
| 410 | - // Set the validation value now |
|
| 411 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * Modify value used for validation |
|
| 417 | - * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
| 418 | - * It also adds any text from the free text fields to the value |
|
| 419 | - * |
|
| 420 | - * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
| 421 | - * |
|
| 422 | - * @since 2.0 |
|
| 423 | - * |
|
| 424 | - * @param string|array $value |
|
| 425 | - * @param string|array $other_vals (usually of posted values) |
|
| 426 | - * @param object $field |
|
| 427 | - * @param array $args |
|
| 428 | - */ |
|
| 429 | - public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
| 430 | - // Checkboxes and multi-select dropdowns |
|
| 431 | - if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
| 432 | - // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
| 433 | - $value = array_merge( $value, $other_vals ); |
|
| 434 | - $value = array_filter( $value ); |
|
| 435 | - if ( count( $value ) == 0 ) { |
|
| 436 | - $value = ''; |
|
| 437 | - } |
|
| 438 | - } else { |
|
| 404 | + // Save original value |
|
| 405 | + $args['temp_value'] = $value; |
|
| 406 | + $args['other'] = true; |
|
| 407 | + |
|
| 408 | + $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 409 | + |
|
| 410 | + // Set the validation value now |
|
| 411 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * Modify value used for validation |
|
| 417 | + * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
| 418 | + * It also adds any text from the free text fields to the value |
|
| 419 | + * |
|
| 420 | + * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
| 421 | + * |
|
| 422 | + * @since 2.0 |
|
| 423 | + * |
|
| 424 | + * @param string|array $value |
|
| 425 | + * @param string|array $other_vals (usually of posted values) |
|
| 426 | + * @param object $field |
|
| 427 | + * @param array $args |
|
| 428 | + */ |
|
| 429 | + public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
| 430 | + // Checkboxes and multi-select dropdowns |
|
| 431 | + if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
| 432 | + // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
| 433 | + $value = array_merge( $value, $other_vals ); |
|
| 434 | + $value = array_filter( $value ); |
|
| 435 | + if ( count( $value ) == 0 ) { |
|
| 436 | + $value = ''; |
|
| 437 | + } |
|
| 438 | + } else { |
|
| 439 | 439 | // Radio and dropdowns |
| 440 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 441 | - $other_key = reset( $other_key ); |
|
| 440 | + $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 441 | + $other_key = reset( $other_key ); |
|
| 442 | 442 | |
| 443 | - // Multi-select dropdown |
|
| 444 | - if ( is_array( $value ) ) { |
|
| 445 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 443 | + // Multi-select dropdown |
|
| 444 | + if ( is_array( $value ) ) { |
|
| 445 | + $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 446 | 446 | |
| 447 | 447 | if ( $o_key !== false ) { |
| 448 | 448 | // Modify the original value so other key will be preserved |
@@ -457,20 +457,20 @@ discard block |
||
| 457 | 457 | $args['temp_value'] = $value; |
| 458 | 458 | $value[ $other_key ] = reset( $other_vals ); |
| 459 | 459 | } |
| 460 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
| 461 | - $value = $other_vals; |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - } |
|
| 460 | + } else if ( $field->options[ $other_key ] == $value ) { |
|
| 461 | + $value = $other_vals; |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | 466 | public static function enqueue_scripts( $params ) { |
| 467 | 467 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' ); |
| 468 | 468 | FrmFormsController::enqueue_scripts( $params ); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - // Add submitted values to a string for spam checking |
|
| 471 | + // Add submitted values to a string for spam checking |
|
| 472 | 472 | public static function entry_array_to_string( $values ) { |
| 473 | - $content = ''; |
|
| 473 | + $content = ''; |
|
| 474 | 474 | foreach ( $values['item_meta'] as $val ) { |
| 475 | 475 | if ( $content != '' ) { |
| 476 | 476 | $content .= "\n\n"; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | return $content; |
| 488 | - } |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | 490 | /** |
| 491 | 491 | * 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 | |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
| 9 | 9 | $values = array(); |
| 10 | 10 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
| 11 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' ); |
|
| 11 | + $values[$var] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | $values['fields'] = array(); |
| 15 | - if ( empty($fields) ) { |
|
| 16 | - return apply_filters('frm_setup_new_entry', $values); |
|
| 15 | + if ( empty( $fields ) ) { |
|
| 16 | + return apply_filters( 'frm_setup_new_entry', $values ); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | foreach ( (array) $fields as $field ) { |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | 'default_value' => $field->default_value, |
| 26 | 26 | 'name' => $field->name, |
| 27 | 27 | 'description' => $field->description, |
| 28 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 28 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), |
|
| 29 | 29 | 'options' => $field->options, |
| 30 | 30 | 'required' => $field->required, |
| 31 | 31 | 'field_key' => $field->field_key, |
@@ -41,38 +41,38 @@ discard block |
||
| 41 | 41 | $opt_defaults['original_type'] = $field->type; |
| 42 | 42 | |
| 43 | 43 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 44 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 45 | - unset($opt, $default_opt); |
|
| 44 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; |
|
| 45 | + unset( $opt, $default_opt ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - unset($opt_defaults); |
|
| 48 | + unset( $opt_defaults ); |
|
| 49 | 49 | |
| 50 | 50 | if ( $field_array['custom_html'] == '' ) { |
| 51 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 51 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 54 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 55 | 55 | $field_array = array_merge( $field->field_options, $field_array ); |
| 56 | 56 | |
| 57 | 57 | $values['fields'][] = $field_array; |
| 58 | 58 | |
| 59 | - if ( ! $form || ! isset($form->id) ) { |
|
| 60 | - $form = FrmForm::getOne($field->form_id); |
|
| 59 | + if ( ! $form || ! isset( $form->id ) ) { |
|
| 60 | + $form = FrmForm::getOne( $field->form_id ); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $form->options = maybe_unserialize($form->options); |
|
| 65 | - if ( is_array($form->options) ) { |
|
| 64 | + $form->options = maybe_unserialize( $form->options ); |
|
| 65 | + if ( is_array( $form->options ) ) { |
|
| 66 | 66 | foreach ( $form->options as $opt => $value ) { |
| 67 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
| 68 | - unset($opt, $value); |
|
| 67 | + $values[$opt] = FrmAppHelper::get_post_param( $opt, $value ); |
|
| 68 | + unset( $opt, $value ); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 73 | 73 | |
| 74 | 74 | $frm_settings = FrmAppHelper::get_settings(); |
| 75 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
| 75 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
| 76 | 76 | |
| 77 | 77 | $values = array_merge( $form_defaults, $values ); |
| 78 | 78 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
| 96 | 96 | |
| 97 | 97 | // Do any shortcodes in default value and allow customization of default value |
| 98 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array); |
|
| 98 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array ); |
|
| 99 | 99 | // Calls FrmProFieldsHelper::get_default_value |
| 100 | 100 | |
| 101 | 101 | $new_value = $field->default_value; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | if ( ! is_array( $new_value ) ) { |
| 117 | - $new_value = str_replace('"', '"', $new_value); |
|
| 117 | + $new_value = str_replace( '"', '"', $new_value ); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $new_value; |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | if ( $_POST ) { |
| 134 | 134 | $repeating = isset( $args['repeating'] ) && $args['repeating']; |
| 135 | 135 | if ( $repeating ) { |
| 136 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { |
|
| 136 | + if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) { |
|
| 137 | 137 | $value_is_posted = true; |
| 138 | 138 | } |
| 139 | - } else if ( isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
| 139 | + } else if ( isset( $_POST['item_meta'][$field->id] ) ) { |
|
| 140 | 140 | $value_is_posted = true; |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
| 148 | 148 | $values['form_id'] = $record->form_id; |
| 149 | 149 | $values['is_draft'] = $record->is_draft; |
| 150 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 150 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public static function get_admin_params( $form = null ) { |
@@ -176,22 +176,22 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | public static function replace_default_message( $message, $atts ) { |
| 179 | - if ( strpos($message, '[default-message') === false && |
|
| 180 | - strpos($message, '[default_message') === false && |
|
| 179 | + if ( strpos( $message, '[default-message' ) === false && |
|
| 180 | + strpos( $message, '[default_message' ) === false && |
|
| 181 | 181 | ! empty( $message ) ) { |
| 182 | 182 | return $message; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( empty($message) ) { |
|
| 185 | + if ( empty( $message ) ) { |
|
| 186 | 186 | $message = '[default-message]'; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 189 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
|
| 190 | 190 | |
| 191 | 191 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 192 | - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 192 | + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
| 193 | 193 | if ( ! empty( $add_atts ) ) { |
| 194 | - $this_atts = array_merge($atts, $add_atts); |
|
| 194 | + $this_atts = array_merge( $atts, $add_atts ); |
|
| 195 | 195 | } else { |
| 196 | 196 | $this_atts = $atts; |
| 197 | 197 | } |
@@ -199,32 +199,32 @@ discard block |
||
| 199 | 199 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
| 200 | 200 | |
| 201 | 201 | // Add the default message |
| 202 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 202 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | return $message; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 209 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
| 209 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
| 210 | 210 | |
| 211 | 211 | if ( FrmAppHelper::pro_is_installed() ) { |
| 212 | 212 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 216 | - return self::display_value($field_value, $field, $atts); |
|
| 215 | + if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
|
| 216 | + return self::display_value( $field_value, $field, $atts ); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // this is an embeded form |
| 220 | 220 | $val = ''; |
| 221 | 221 | |
| 222 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 222 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
|
| 223 | 223 | //this is a repeating section |
| 224 | 224 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
| 225 | 225 | } else { |
| 226 | 226 | // get all values for this field |
| 227 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 227 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
| 228 | 228 | |
| 229 | 229 | if ( $child_values ) { |
| 230 | 230 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | $field_value = array(); |
| 235 | 235 | |
| 236 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 236 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 237 | 237 | return $val; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | $atts['post_id'] = $child_entry->post_id; |
| 243 | 243 | |
| 244 | 244 | // get the value for this field -- check for post values as well |
| 245 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 245 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
|
| 246 | 246 | |
| 247 | 247 | if ( $entry_val ) { |
| 248 | 248 | // foreach entry get display_value |
| 249 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 249 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - unset($child_entry); |
|
| 252 | + unset( $child_entry ); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $val = implode(', ', (array) $field_value ); |
|
| 255 | + $val = implode( ', ', (array) $field_value ); |
|
| 256 | 256 | $val = wp_kses_post( $val ); |
| 257 | 257 | |
| 258 | 258 | return $val; |
@@ -272,22 +272,22 @@ discard block |
||
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | 274 | $atts = wp_parse_args( $atts, $defaults ); |
| 275 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 275 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
|
| 276 | 276 | |
| 277 | - if ( ! isset($field->field_options['post_field']) ) { |
|
| 277 | + if ( ! isset( $field->field_options['post_field'] ) ) { |
|
| 278 | 278 | $field->field_options['post_field'] = ''; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 281 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
| 282 | 282 | $field->field_options['custom_field'] = ''; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
| 286 | 286 | $atts['pre_truncate'] = $atts['truncate']; |
| 287 | 287 | $atts['truncate'] = true; |
| 288 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 288 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
|
| 289 | 289 | |
| 290 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 290 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
|
| 291 | 291 | $atts['truncate'] = $atts['pre_truncate']; |
| 292 | 292 | } |
| 293 | 293 | |
@@ -295,39 +295,39 @@ discard block |
||
| 295 | 295 | return $value; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 298 | + $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts ); |
|
| 299 | 299 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
| 300 | 300 | |
| 301 | 301 | $new_value = ''; |
| 302 | 302 | |
| 303 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 303 | + if ( is_array( $value ) && $atts['type'] != 'file' ) { |
|
| 304 | 304 | foreach ( $value as $val ) { |
| 305 | - if ( is_array($val) ) { |
|
| 305 | + if ( is_array( $val ) ) { |
|
| 306 | 306 | //TODO: add options for display (li or ,) |
| 307 | - $new_value .= implode($atts['sep'], $val); |
|
| 307 | + $new_value .= implode( $atts['sep'], $val ); |
|
| 308 | 308 | if ( $atts['type'] != 'data' ) { |
| 309 | 309 | $new_value .= '<br/>'; |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | - unset($val); |
|
| 312 | + unset( $val ); |
|
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ( ! empty($new_value) ) { |
|
| 316 | + if ( ! empty( $new_value ) ) { |
|
| 317 | 317 | $value = $new_value; |
| 318 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 319 | - $value = implode($atts['sep'], $value); |
|
| 318 | + } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 319 | + $value = implode( $atts['sep'], $value ); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
| 323 | - $value = FrmAppHelper::truncate($value, 50); |
|
| 323 | + $value = FrmAppHelper::truncate( $value, 50 ); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
| 327 | 327 | $value = wp_kses_post( $value ); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 330 | + return apply_filters( 'frm_display_value', $value, $field, $atts ); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | public static function set_posted_value( $field, $value, $args ) { |
@@ -335,20 +335,20 @@ discard block |
||
| 335 | 335 | if ( isset( $args['other'] ) && $args['other'] ) { |
| 336 | 336 | $value = $args['temp_value']; |
| 337 | 337 | } |
| 338 | - if ( empty($args['parent_field_id']) ) { |
|
| 339 | - $_POST['item_meta'][ $field->id ] = $value; |
|
| 338 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 339 | + $_POST['item_meta'][$field->id] = $value; |
|
| 340 | 340 | } else { |
| 341 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 341 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | public static function get_posted_value( $field, &$value, $args ) { |
| 346 | 346 | $field_id = is_object( $field ) ? $field->id : $field; |
| 347 | 347 | |
| 348 | - if ( empty($args['parent_field_id']) ) { |
|
| 349 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 348 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 349 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; |
|
| 350 | 350 | } else { |
| 351 | - $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 ] : ''; |
|
| 351 | + $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] : ''; |
|
| 352 | 352 | } |
| 353 | 353 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 354 | 354 | $value = stripslashes_deep( $value ); |
@@ -373,12 +373,12 @@ discard block |
||
| 373 | 373 | self::set_other_repeating_vals( $field, $value, $args ); |
| 374 | 374 | |
| 375 | 375 | // Check if there are any posted "Other" values |
| 376 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
| 376 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
| 377 | 377 | |
| 378 | 378 | // Save original value |
| 379 | 379 | $args['temp_value'] = $value; |
| 380 | 380 | $args['other'] = true; |
| 381 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 381 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); |
|
| 382 | 382 | |
| 383 | 383 | // Set the validation value now |
| 384 | 384 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -400,12 +400,12 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | // Check if there are any other posted "other" values for this field |
| 403 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
| 403 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
| 404 | 404 | // Save original value |
| 405 | 405 | $args['temp_value'] = $value; |
| 406 | 406 | $args['other'] = true; |
| 407 | 407 | |
| 408 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 408 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; |
|
| 409 | 409 | |
| 410 | 410 | // Set the validation value now |
| 411 | 411 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -437,27 +437,27 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | } else { |
| 439 | 439 | // Radio and dropdowns |
| 440 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 440 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); |
|
| 441 | 441 | $other_key = reset( $other_key ); |
| 442 | 442 | |
| 443 | 443 | // Multi-select dropdown |
| 444 | 444 | if ( is_array( $value ) ) { |
| 445 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 445 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
| 446 | 446 | |
| 447 | 447 | if ( $o_key !== false ) { |
| 448 | 448 | // Modify the original value so other key will be preserved |
| 449 | - $value[ $other_key ] = $value[ $o_key ]; |
|
| 449 | + $value[$other_key] = $value[$o_key]; |
|
| 450 | 450 | |
| 451 | 451 | // By default, the array keys will be numeric for multi-select dropdowns |
| 452 | 452 | // If going backwards and forwards between pages, the array key will match the other key |
| 453 | 453 | if ( $o_key != $other_key ) { |
| 454 | - unset( $value[ $o_key ] ); |
|
| 454 | + unset( $value[$o_key] ); |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | $args['temp_value'] = $value; |
| 458 | - $value[ $other_key ] = reset( $other_vals ); |
|
| 458 | + $value[$other_key] = reset( $other_vals ); |
|
| 459 | 459 | } |
| 460 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
| 460 | + } else if ( $field->options[$other_key] == $value ) { |
|
| 461 | 461 | $value = $other_vals; |
| 462 | 462 | } |
| 463 | 463 | } |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $content .= "\n\n"; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - if ( is_array($val) ) { |
|
| 479 | + if ( is_array( $val ) ) { |
|
| 480 | 480 | $val = FrmAppHelper::array_flatten( $val ); |
| 481 | 481 | $val = implode( ', ', $val ); |
| 482 | 482 | } |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers |
| 541 | 541 | |
| 542 | 542 | // see how many we have |
| 543 | - $i = count($matches['browser']); |
|
| 543 | + $i = count( $matches['browser'] ); |
|
| 544 | 544 | |
| 545 | 545 | if ( $i > 1 ) { |
| 546 | 546 | //we will have two since we are not using 'other' argument yet |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | function load_formidable_forms() { |
| 26 | 26 | global $frm_vars; |
| 27 | 27 | $frm_vars = array( |
| 28 | - 'load_css' => false, 'forms_loaded' => array(), |
|
| 29 | - 'created_entries' => array(), |
|
| 30 | - 'pro_is_authorized' => false, |
|
| 28 | + 'load_css' => false, 'forms_loaded' => array(), |
|
| 29 | + 'created_entries' => array(), |
|
| 30 | + 'pro_is_authorized' => false, |
|
| 31 | 31 | ); |
| 32 | 32 | |
| 33 | 33 | // if __autoload is active, put it on the spl_autoload stack |
| 34 | 34 | if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions() ) ) { |
| 35 | - spl_autoload_register('__autoload'); |
|
| 35 | + spl_autoload_register('__autoload'); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Add the autoloader |
@@ -45,33 +45,33 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | function frm_forms_autoloader( $class_name ) { |
| 48 | - // Only load Frm classes here |
|
| 48 | + // Only load Frm classes here |
|
| 49 | 49 | if ( ! preg_match( '/^Frm.+$/', $class_name ) || preg_match( '/^FrmPro.+$/', $class_name ) ) { |
| 50 | - return; |
|
| 51 | - } |
|
| 50 | + return; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | frm_forms_load_class( $class_name, dirname( __FILE__ ) ); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | function frm_forms_load_class( $class_name, $filepath ) { |
| 57 | - $filepath .= '/classes'; |
|
| 57 | + $filepath .= '/classes'; |
|
| 58 | 58 | |
| 59 | 59 | if ( preg_match( '/^.+Helper$/', $class_name ) ) { |
| 60 | - $filepath .= '/helpers/'; |
|
| 60 | + $filepath .= '/helpers/'; |
|
| 61 | 61 | } else if ( preg_match( '/^.+Controller$/', $class_name ) ) { |
| 62 | - $filepath .= '/controllers/'; |
|
| 62 | + $filepath .= '/controllers/'; |
|
| 63 | 63 | } else if ( preg_match( '/^.+Factory$/', $class_name ) ) { |
| 64 | 64 | $filepath .= '/factories/'; |
| 65 | - } else { |
|
| 66 | - $filepath .= '/models/'; |
|
| 65 | + } else { |
|
| 66 | + $filepath .= '/models/'; |
|
| 67 | 67 | if ( ! file_exists( $filepath . $class_name . '.php' ) ) { |
| 68 | 68 | $filepath .= 'fields/'; |
| 69 | 69 | } |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | $filepath .= $class_name . '.php'; |
| 73 | 73 | |
| 74 | - if ( file_exists( $filepath ) ) { |
|
| 75 | - include( $filepath ); |
|
| 76 | - } |
|
| 74 | + if ( file_exists( $filepath ) ) { |
|
| 75 | + include( $filepath ); |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | |
| 33 | 33 | // if __autoload is active, put it on the spl_autoload stack |
| 34 | 34 | if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions() ) ) { |
| 35 | - spl_autoload_register('__autoload'); |
|
| 35 | + spl_autoload_register( '__autoload' ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Add the autoloader |
| 39 | - spl_autoload_register('frm_forms_autoloader'); |
|
| 39 | + spl_autoload_register( 'frm_forms_autoloader' ); |
|
| 40 | 40 | |
| 41 | 41 | FrmHooksController::trigger_load_hook(); |
| 42 | 42 | |