@@ -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', FrmAppHelper::plugin_url() . '/images/form_16.png', 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,39 +19,39 @@ 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 | - global $pagenow, $frm_vars; |
|
| 27 | + global $pagenow, $frm_vars; |
|
| 28 | 28 | |
| 29 | 29 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 30 | - if ( empty( $show_nav ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 30 | + if ( empty( $show_nav ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | $current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); |
| 35 | 35 | if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) { |
| 36 | 36 | $current_page = 'frm_display'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( $form ) { |
|
| 39 | + if ( $form ) { |
|
| 40 | 40 | FrmForm::maybe_get_form( $form ); |
| 41 | 41 | |
| 42 | - if ( is_object( $form ) ) { |
|
| 43 | - $id = $form->id; |
|
| 44 | - } |
|
| 45 | - } |
|
| 42 | + if ( is_object( $form ) ) { |
|
| 43 | + $id = $form->id; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - if ( ! isset( $id ) ) { |
|
| 48 | - $form = $id = false; |
|
| 49 | - } |
|
| 47 | + if ( ! isset( $id ) ) { |
|
| 48 | + $form = $id = false; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | $nav_items = self::get_form_nav_items( $id ); |
| 52 | 52 | |
| 53 | - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
| 54 | - } |
|
| 53 | + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | private static function get_form_nav_items( $id ) { |
| 57 | 57 | $nav_items = array( |
@@ -82,28 +82,28 @@ discard block |
||
| 82 | 82 | return $nav_items; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - // Adds a settings link to the plugins page |
|
| 86 | - public static function settings_link( $links ) { |
|
| 85 | + // Adds a settings link to the plugins page |
|
| 86 | + public static function settings_link( $links ) { |
|
| 87 | 87 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 88 | - array_unshift( $links, $settings ); |
|
| 88 | + array_unshift( $links, $settings ); |
|
| 89 | 89 | |
| 90 | - return $links; |
|
| 91 | - } |
|
| 90 | + return $links; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public static function pro_get_started_headline() { |
|
| 93 | + public static function pro_get_started_headline() { |
|
| 94 | 94 | self::maybe_show_upgrade_bar(); |
| 95 | 95 | |
| 96 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 97 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 98 | - return; |
|
| 99 | - } |
|
| 96 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 97 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
| 102 | - FrmAppHelper::load_admin_wide_js(); |
|
| 102 | + FrmAppHelper::load_admin_wide_js(); |
|
| 103 | 103 | |
| 104 | - // user is authorized, but running free version |
|
| 105 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 106 | - ?> |
|
| 104 | + // user is authorized, but running free version |
|
| 105 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 106 | + ?> |
|
| 107 | 107 | <div class="error" class="frm_previous_install"> |
| 108 | 108 | <?php |
| 109 | 109 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | ) ); ?> |
| 116 | 116 | </div> |
| 117 | 117 | <?php |
| 118 | - } |
|
| 119 | - } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | private static function maybe_show_upgrade_bar() { |
| 122 | 122 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - public static function admin_js() { |
|
| 219 | + public static function admin_js() { |
|
| 220 | 220 | $version = FrmAppHelper::plugin_version(); |
| 221 | 221 | FrmAppHelper::load_admin_wide_js( false ); |
| 222 | 222 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
| 228 | 228 | ), $version, true ); |
| 229 | 229 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 230 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 230 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 231 | 231 | |
| 232 | 232 | // load multselect js |
| 233 | 233 | wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true ); |
@@ -238,79 +238,79 @@ discard block |
||
| 238 | 238 | global $pagenow; |
| 239 | 239 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 240 | 240 | |
| 241 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 242 | - wp_enqueue_style( 'widgets' ); |
|
| 243 | - wp_enqueue_script( 'formidable' ); |
|
| 244 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 241 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 242 | + wp_enqueue_style( 'widgets' ); |
|
| 243 | + wp_enqueue_script( 'formidable' ); |
|
| 244 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 245 | 245 | FrmAppHelper::localize_script( 'admin' ); |
| 246 | 246 | |
| 247 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 247 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 248 | 248 | FrmStylesController::enqueue_css( 'admin' ); |
| 249 | - add_thickbox(); |
|
| 249 | + add_thickbox(); |
|
| 250 | 250 | |
| 251 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 251 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 252 | 252 | |
| 253 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 254 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 255 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 253 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 254 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 255 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 256 | 256 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 257 | 257 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 258 | - if ( ! $post ) { |
|
| 259 | - return; |
|
| 260 | - } |
|
| 261 | - $post_type = $post->post_type; |
|
| 262 | - } else { |
|
| 263 | - return; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - if ( $post_type == 'frm_display' ) { |
|
| 267 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 268 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 269 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 258 | + if ( ! $post ) { |
|
| 259 | + return; |
|
| 260 | + } |
|
| 261 | + $post_type = $post->post_type; |
|
| 262 | + } else { |
|
| 263 | + return; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + if ( $post_type == 'frm_display' ) { |
|
| 267 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 268 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 269 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 270 | 270 | FrmAppHelper::localize_script( 'admin' ); |
| 271 | - } |
|
| 272 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 273 | - FrmAppHelper::load_admin_wide_js(); |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - public static function wp_admin_body_class( $classes ) { |
|
| 278 | - global $wp_version; |
|
| 279 | - //we need this class everywhere in the admin for the menu |
|
| 280 | - if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
| 281 | - $classes .= ' frm_38_trigger'; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - return $classes; |
|
| 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 | - |
|
| 299 | - public static function widget_text_filter_callback( $matches ) { |
|
| 300 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
| 301 | - return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - public static function front_head() { |
|
| 305 | - if ( is_multisite() ) { |
|
| 306 | - $old_db_version = get_option( 'frm_db_version' ); |
|
| 307 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 308 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 309 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 310 | - self::install( $old_db_version ); |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - } |
|
| 271 | + } |
|
| 272 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 273 | + FrmAppHelper::load_admin_wide_js(); |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + public static function wp_admin_body_class( $classes ) { |
|
| 278 | + global $wp_version; |
|
| 279 | + //we need this class everywhere in the admin for the menu |
|
| 280 | + if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
| 281 | + $classes .= ' frm_38_trigger'; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + return $classes; |
|
| 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 | + |
|
| 299 | + public static function widget_text_filter_callback( $matches ) { |
|
| 300 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
| 301 | + return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + public static function front_head() { |
|
| 305 | + if ( is_multisite() ) { |
|
| 306 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 307 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 308 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 309 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 310 | + self::install( $old_db_version ); |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | public static function localize_script( $location ) { |
| 316 | 316 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -370,20 +370,20 @@ discard block |
||
| 370 | 370 | wp_die(); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - public static function activation_install() { |
|
| 374 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 375 | - FrmFormActionsController::actions_init(); |
|
| 376 | - self::install(); |
|
| 377 | - } |
|
| 373 | + public static function activation_install() { |
|
| 374 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 375 | + FrmFormActionsController::actions_init(); |
|
| 376 | + self::install(); |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - public static function install( $old_db_version = false ) { |
|
| 380 | - $frmdb = new FrmDb(); |
|
| 381 | - $frmdb->upgrade( $old_db_version ); |
|
| 382 | - } |
|
| 379 | + public static function install( $old_db_version = false ) { |
|
| 380 | + $frmdb = new FrmDb(); |
|
| 381 | + $frmdb->upgrade( $old_db_version ); |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - public static function uninstall() { |
|
| 384 | + public static function uninstall() { |
|
| 385 | 385 | FrmAppHelper::permission_check('administrator'); |
| 386 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 386 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 387 | 387 | |
| 388 | 388 | $frmdb = new FrmDb(); |
| 389 | 389 | $frmdb->uninstall(); |
@@ -392,48 +392,48 @@ discard block |
||
| 392 | 392 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 393 | 393 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 394 | 394 | |
| 395 | - wp_die(); |
|
| 396 | - } |
|
| 395 | + wp_die(); |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - public static function drop_tables( $tables ) { |
|
| 399 | - global $wpdb; |
|
| 400 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 401 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 402 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 403 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 404 | - return $tables; |
|
| 405 | - } |
|
| 398 | + public static function drop_tables( $tables ) { |
|
| 399 | + global $wpdb; |
|
| 400 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 401 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 402 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 403 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 404 | + return $tables; |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 408 | - public static function page_route( $content ) { |
|
| 409 | - global $post; |
|
| 407 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 408 | + public static function page_route( $content ) { |
|
| 409 | + global $post; |
|
| 410 | 410 | |
| 411 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 412 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 413 | - $content = FrmFormsController::page_preview(); |
|
| 414 | - } |
|
| 411 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 412 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 413 | + $content = FrmFormsController::page_preview(); |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - return $content; |
|
| 417 | - } |
|
| 416 | + return $content; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - public static function deauthorize() { |
|
| 419 | + public static function deauthorize() { |
|
| 420 | 420 | FrmAppHelper::permission_check('frm_change_settings'); |
| 421 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 422 | - |
|
| 423 | - delete_option( 'frmpro-credentials' ); |
|
| 424 | - delete_option( 'frmpro-authorized' ); |
|
| 425 | - delete_site_option( 'frmpro-credentials' ); |
|
| 426 | - delete_site_option( 'frmpro-authorized' ); |
|
| 427 | - wp_die(); |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - public static function get_form_shortcode( $atts ) { |
|
| 431 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 432 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - public static function get_postbox_class() { |
|
| 436 | - _deprecated_function( __FUNCTION__, '2.0' ); |
|
| 437 | - return 'postbox-container'; |
|
| 438 | - } |
|
| 421 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 422 | + |
|
| 423 | + delete_option( 'frmpro-credentials' ); |
|
| 424 | + delete_option( 'frmpro-authorized' ); |
|
| 425 | + delete_site_option( 'frmpro-credentials' ); |
|
| 426 | + delete_site_option( 'frmpro-authorized' ); |
|
| 427 | + wp_die(); |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + public static function get_form_shortcode( $atts ) { |
|
| 431 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 432 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + public static function get_postbox_class() { |
|
| 436 | + _deprecated_function( __FUNCTION__, '2.0' ); |
|
| 437 | + return 'postbox-container'; |
|
| 438 | + } |
|
| 439 | 439 | } |
@@ -3,48 +3,48 @@ discard block |
||
| 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 | - echo 'rows="'. esc_attr( $field['max'] ) .'" '; |
|
| 6 | + echo 'rows="'. esc_attr( $field['max'] ) .'" '; |
|
| 7 | 7 | } |
| 8 | 8 | do_action('frm_field_input_html', $field); |
| 9 | 9 | ?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea> |
| 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 | - echo ' '. $opt .'</label>'; |
|
| 47 | - } |
|
| 46 | + echo ' '. $opt .'</label>'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | FrmFieldsHelper::include_other_input( array( |
| 50 | 50 | 'other_opt' => $other_opt, 'read_only' => $read_only, |
@@ -53,14 +53,14 @@ 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 | - $read_only = false; |
|
| 63 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 62 | + $read_only = false; |
|
| 63 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 64 | 64 | echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) ); |
| 65 | 65 | } else { |
| 66 | 66 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | ?> |
| 94 | 94 | <option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option> |
| 95 | 95 | <?php |
| 96 | - } ?> |
|
| 96 | + } ?> |
|
| 97 | 97 | </select> |
| 98 | 98 | <?php |
| 99 | 99 | FrmFieldsHelper::include_other_input( array( |
@@ -102,52 +102,52 @@ discard block |
||
| 102 | 102 | 'value' => $other_args['value'], 'field' => $field, |
| 103 | 103 | 'html_id' => $html_id, 'opt_key' => false, |
| 104 | 104 | ) ); |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | } else if ( $field['type'] == 'checkbox' ) { |
| 107 | - $checked_values = $field['value']; |
|
| 108 | - $read_only = false; |
|
| 107 | + $checked_values = $field['value']; |
|
| 108 | + $read_only = false; |
|
| 109 | 109 | |
| 110 | 110 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
| 111 | - $read_only = true; |
|
| 112 | - if ( $checked_values ) { |
|
| 113 | - foreach ( (array) $checked_values as $checked_value ) { ?> |
|
| 111 | + $read_only = true; |
|
| 112 | + if ( $checked_values ) { |
|
| 113 | + foreach ( (array) $checked_values as $checked_value ) { ?> |
|
| 114 | 114 | <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> |
| 115 | 115 | <?php |
| 116 | - } |
|
| 117 | - } else { ?> |
|
| 116 | + } |
|
| 117 | + } else { ?> |
|
| 118 | 118 | <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" /> |
| 119 | 119 | <?php |
| 120 | - } |
|
| 121 | - } |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 123 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 124 | 124 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 125 | - } else if ( $field['options'] ) { |
|
| 126 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 127 | - if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) { |
|
| 128 | - continue; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 132 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 133 | - $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 134 | - |
|
| 135 | - // Check if other opt, and get values for other field if needed |
|
| 136 | - $other_opt = false; |
|
| 125 | + } else if ( $field['options'] ) { |
|
| 126 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 127 | + if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) { |
|
| 128 | + continue; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 132 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 133 | + $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 134 | + |
|
| 135 | + // Check if other opt, and get values for other field if needed |
|
| 136 | + $other_opt = false; |
|
| 137 | 137 | $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked ); |
| 138 | 138 | |
| 139 | - ?> |
|
| 139 | + ?> |
|
| 140 | 140 | <div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
| 141 | 141 | |
| 142 | - if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 143 | - ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
|
| 144 | - } |
|
| 142 | + if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 143 | + ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - ?><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 |
|
| 146 | + ?><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 |
|
| 147 | 147 | |
| 148 | - if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 149 | - echo ' '. $opt .'</label>'; |
|
| 150 | - } |
|
| 148 | + if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 149 | + echo ' '. $opt .'</label>'; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | FrmFieldsHelper::include_other_input( array( |
| 153 | 153 | 'other_opt' => $other_opt, 'read_only' => $read_only, |
@@ -156,17 +156,17 @@ discard block |
||
| 156 | 156 | 'html_id' => $html_id, 'opt_key' => $opt_key, |
| 157 | 157 | ) ); |
| 158 | 158 | |
| 159 | - unset( $other_opt, $other_args, $checked ); |
|
| 159 | + unset( $other_opt, $other_args, $checked ); |
|
| 160 | 160 | |
| 161 | - ?></div> |
|
| 161 | + ?></div> |
|
| 162 | 162 | <?php |
| 163 | - } |
|
| 164 | - } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) { |
| 166 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 167 | - if ( ! empty($frm_settings->pubkey) ) { |
|
| 168 | - FrmFieldsHelper::display_recaptcha($field); |
|
| 169 | - } |
|
| 166 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 167 | + if ( ! empty($frm_settings->pubkey) ) { |
|
| 168 | + FrmFieldsHelper::display_recaptcha($field); |
|
| 169 | + } |
|
| 170 | 170 | } else { |
| 171 | 171 | do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) ); |
| 172 | 172 | 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' ) ) ) { ?> |
| 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 | - echo 'rows="'. esc_attr( $field['max'] ) .'" '; |
|
| 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,33 +17,33 @@ 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'] ) { |
| 46 | - echo ' '. $opt .'</label>'; |
|
| 46 | + echo ' ' . $opt . '</label>'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | FrmFieldsHelper::include_other_input( array( |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | } else if ( $field['type'] == 'select' ) { |
| 62 | 62 | $read_only = false; |
| 63 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 63 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 64 | 64 | echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) ); |
| 65 | 65 | } else { |
| 66 | 66 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | <input type="hidden" value="<?php echo esc_attr( $selected_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> <?php |
| 72 | 72 | } |
| 73 | 73 | } else { ?> |
| 74 | - <input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php |
|
| 74 | + <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php |
|
| 75 | 75 | } ?> |
| 76 | - <select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>> <?php |
|
| 76 | + <select disabled="disabled" <?php do_action( 'frm_field_input_html', $field ) ?>> <?php |
|
| 77 | 77 | |
| 78 | 78 | } else { ?> |
| 79 | -<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>> |
|
| 79 | +<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>> |
|
| 80 | 80 | <?php } |
| 81 | 81 | |
| 82 | 82 | $other_opt = $other_checked = false; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | ?> |
| 94 | - <option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option> |
|
| 94 | + <option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo ( $opt == '' ) ? ' ' : $opt; ?></option> |
|
| 95 | 95 | <?php |
| 96 | 96 | } ?> |
| 97 | 97 | </select> |
@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 123 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 124 | 124 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 125 | 125 | } else if ( $field['options'] ) { |
| 126 | 126 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 127 | - if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) { |
|
| 127 | + if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) { |
|
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 132 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 133 | - $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 131 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 132 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 133 | + $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : ''; |
|
| 134 | 134 | |
| 135 | 135 | // Check if other opt, and get values for other field if needed |
| 136 | 136 | $other_opt = false; |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - ?><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 |
|
| 146 | + ?><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 |
|
| 147 | 147 | |
| 148 | 148 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 149 | - echo ' '. $opt .'</label>'; |
|
| 149 | + echo ' ' . $opt . '</label>'; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | FrmFieldsHelper::include_other_input( array( |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) { |
| 166 | 166 | $frm_settings = FrmAppHelper::get_settings(); |
| 167 | - if ( ! empty($frm_settings->pubkey) ) { |
|
| 168 | - FrmFieldsHelper::display_recaptcha($field); |
|
| 167 | + if ( ! empty( $frm_settings->pubkey ) ) { |
|
| 168 | + FrmFieldsHelper::display_recaptcha( $field ); |
|
| 169 | 169 | } |
| 170 | 170 | } else { |
| 171 | 171 | do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) ); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <div class="wrap"> |
| 2 | 2 | <div class="frmicon icon32"><br/></div> |
| 3 | - <h2><?php echo ( $form->is_template ? __( 'Templates', 'formidable' ) : __( 'Build', 'formidable' )); ?> |
|
| 3 | + <h2><?php echo ( $form->is_template ? __( 'Templates', 'formidable' ) : __( 'Build', 'formidable' ) ); ?> |
|
| 4 | 4 | <a href="?page=formidable&frm_action=new" class="add-new-h2"><?php _e( 'Add New', 'formidable' ); ?></a> |
| 5 | 5 | </h2> |
| 6 | 6 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | <input type="hidden" name="action" value="update" /> |
| 34 | 34 | <input type="hidden" name="id" id="form_id" value="<?php echo (int) $id; ?>" /> |
| 35 | 35 | |
| 36 | - <?php require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/form.php'); ?> |
|
| 36 | + <?php require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/form.php' ); ?> |
|
| 37 | 37 | |
| 38 | 38 | <p> |
| 39 | 39 | <input type="button" value="<?php esc_attr_e( 'Update', 'formidable' ) ?>" class="frm_submit_<?php echo ( isset( $values['ajax_load'] ) && $values['ajax_load'] ) ? '' : 'no_'; ?>ajax button-primary" /> |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | </form> |
| 43 | 43 | </div> |
| 44 | 44 | </div> |
| 45 | - <?php require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field_links.php'); ?> |
|
| 45 | + <?php require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field_links.php' ); ?> |
|
| 46 | 46 | </div> |
| 47 | 47 | </div> |
| 48 | 48 | </div> |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$display = apply_filters('frm_display_field_options', array( |
|
| 3 | +$display = apply_filters( 'frm_display_field_options', array( |
|
| 4 | 4 | 'type' => $field['type'], 'field_data' => $field, |
| 5 | 5 | 'required' => true, 'unique' => false, 'read_only' => false, |
| 6 | 6 | 'description' => true, 'options' => true, 'label_position' => true, |
| 7 | 7 | 'invalid' => false, 'size' => false, 'clear_on_focus' => false, |
| 8 | 8 | 'default_blank' => true, 'css' => true, 'conf_field' => false, |
| 9 | 9 | 'max' => true, 'captcha_size' => false, |
| 10 | -)); |
|
| 10 | +) ); |
|
| 11 | 11 | |
| 12 | -$li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_'. $display['type']; |
|
| 13 | -$li_classes = apply_filters('frm_build_field_class', $li_classes, $field ); |
|
| 12 | +$li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_' . $display['type']; |
|
| 13 | +$li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field ); |
|
| 14 | 14 | |
| 15 | 15 | if ( isset( $values ) && isset( $values['ajax_load'] ) && $values['ajax_load'] && isset( $count ) && $count > 10 && ! in_array( $field['type'], array( 'divider', 'end_divider' ) ) ) { |
| 16 | 16 | ?> |
| 17 | 17 | <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?> frm_field_loading" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo esc_attr( 'divider' == $field['type'] ? $field['form_select'] : $field['form_id'] ); ?>" data-ftype="<?php echo esc_attr( $display['type'] ) ?>"> |
| 18 | 18 | <img src="<?php echo FrmAppHelper::plugin_url() ?>/images/ajax_loader.gif" alt="<?php esc_attr_e( 'Loading', 'formidable' ) ?>" /> |
| 19 | -<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars(json_encode($field)) ?></span> |
|
| 19 | +<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars( json_encode( $field ) ) ?></span> |
|
| 20 | 20 | </li> |
| 21 | 21 | <?php |
| 22 | 22 | return; |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | $frm_settings = FrmAppHelper::get_settings(); |
| 26 | 26 | |
| 27 | 27 | if ( ! isset( $frm_all_field_selection ) ) { |
| 28 | - if ( isset($frm_field_selection) && isset($pro_field_selection) ) { |
|
| 29 | - $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection); |
|
| 28 | + if ( isset( $frm_field_selection ) && isset( $pro_field_selection ) ) { |
|
| 29 | + $frm_all_field_selection = array_merge( $frm_field_selection, $pro_field_selection ); |
|
| 30 | 30 | } else { |
| 31 | 31 | $pro_field_selection = FrmField::pro_field_selection(); |
| 32 | 32 | $frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection ); |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | <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> |
| 52 | 52 | <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> |
| 53 | 53 | <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> |
| 54 | - <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr($field['id']) ?>" /> |
|
| 55 | - <?php do_action('frm_extra_field_actions', $field['id']); ?> |
|
| 54 | + <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr( $field['id'] ) ?>" /> |
|
| 55 | + <?php do_action( 'frm_extra_field_actions', $field['id'] ); ?> |
|
| 56 | 56 | <?php if ( $display['required'] ) { ?> |
| 57 | 57 | <span id="require_field_<?php echo esc_attr( $field['id'] ); ?>"> |
| 58 | 58 | <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> |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | <?php } |
| 61 | 61 | |
| 62 | 62 | ?> |
| 63 | - <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> |
|
| 63 | + <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> |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | <div id="field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_field_container"> |
| 67 | 67 | <div class="frm_form_fields" data-ftype="<?php echo esc_attr( $display['type'] ) ?>"> |
| 68 | 68 | <?php |
| 69 | -include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/show-build.php'); |
|
| 69 | +include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/show-build.php' ); |
|
| 70 | 70 | |
| 71 | 71 | if ( $display['clear_on_focus'] ) { |
| 72 | 72 | FrmFieldsHelper::clear_on_focus_html( $field, $display ); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | </div> |
| 79 | 79 | <?php |
| 80 | 80 | if ( $display['description'] ) { ?> |
| 81 | - <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> |
|
| 81 | + <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> |
|
| 82 | 82 | <input type="hidden" name="field_options[description_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['description'] ); ?>" /> |
| 83 | 83 | |
| 84 | 84 | <?php } ?> |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_container" class="frm_conf_field_container frm_form_fields frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>"> |
| 89 | 89 | <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_conf_container"> |
| 90 | 90 | <div class="frm_form_fields"> |
| 91 | - <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'] ); ?>" <?php do_action('frm_field_input_html', $field) ?> /> |
|
| 91 | + <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'] ); ?>" <?php do_action( 'frm_field_input_html', $field ) ?> /> |
|
| 92 | 92 | </div> |
| 93 | - <div class="frm_ipe_field_conf_desc description <?php echo ($field['conf_desc'] == '') ? 'frm-show-click' : '' ?>"><?php echo ($field['conf_desc'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags($field['conf_desc']); ?></div> |
|
| 93 | + <div class="frm_ipe_field_conf_desc description <?php echo ( $field['conf_desc'] == '' ) ? 'frm-show-click' : '' ?>"><?php echo ( $field['conf_desc'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['conf_desc'] ); ?></div> |
|
| 94 | 94 | <input type="hidden" name="field_options[conf_desc_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_desc'] ); ?>" /> |
| 95 | 95 | </div> |
| 96 | 96 | <?php if ( $display['clear_on_focus'] ) { ?> |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?> |
| 106 | 106 | <div class="frm-show-click frm_small_top_margin"><?php |
| 107 | 107 | |
| 108 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 109 | - echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>'; |
|
| 108 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 109 | + echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>'; |
|
| 110 | 110 | } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { |
| 111 | 111 | ?> |
| 112 | 112 | <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>"> |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | <?php |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
| 123 | - <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"><?php _e( 'Bulk Edit Options', 'formidable' ) ?></a> |
|
| 122 | + if ( ! isset( $field['post_field'] ) || $field['post_field'] != 'post_category' ) { ?> |
|
| 123 | + <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"><?php _e( 'Bulk Edit Options', 'formidable' ) ?></a> |
|
| 124 | 124 | <?php } ?> |
| 125 | 125 | </div> |
| 126 | 126 | <?php |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | <?php |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | -do_action('frm_before_field_options', $field); |
|
| 133 | +do_action( 'frm_before_field_options', $field ); |
|
| 134 | 134 | |
| 135 | 135 | if ( $display['options'] ) { ?> |
| 136 | 136 | <div class="widget"> |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | </div> |
| 141 | 141 | <div class="widget-inside"> |
| 142 | 142 | <table class="form-table frm_clear_none"> |
| 143 | - <?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?> |
|
| 143 | + <?php $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); ?> |
|
| 144 | 144 | <tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td> |
| 145 | 145 | <td> |
| 146 | - <select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
| 146 | + <select <?php if ( count( $field_types ) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
| 147 | 147 | <?php |
| 148 | 148 | foreach ( $field_types as $fkey => $ftype ) { ?> |
| 149 | - <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> |
|
| 149 | + <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> |
|
| 150 | 150 | <?php |
| 151 | 151 | unset( $fkey, $ftype ); |
| 152 | 152 | } ?> |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | <?php |
| 156 | 156 | if ( $display['required'] ) { ?> |
| 157 | - <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"': ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label> |
|
| 157 | + <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"' : ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label> |
|
| 158 | 158 | <?php |
| 159 | 159 | } |
| 160 | 160 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | <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' ) ?>" ><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 echo $field['read_only'] ? ' checked="checked"' : ''; ?>/> <?php _e( 'Read Only', 'formidable' ) ?></label> |
| 176 | 176 | <?php } |
| 177 | 177 | |
| 178 | - do_action('frm_field_options_form_top', $field, $display, $values); |
|
| 178 | + do_action( 'frm_field_options_form_top', $field, $display, $values ); |
|
| 179 | 179 | |
| 180 | 180 | ?> |
| 181 | 181 | <?php |
@@ -212,13 +212,13 @@ discard block |
||
| 212 | 212 | if ( $display['label_position'] ) { ?> |
| 213 | 213 | <tr><td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td> |
| 214 | 214 | <td><select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]"> |
| 215 | - <option value=""<?php selected($field['label'], ''); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 216 | - <option value="top"<?php selected($field['label'], 'top'); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
| 217 | - <option value="left"<?php selected($field['label'], 'left'); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
| 218 | - <option value="right"<?php selected($field['label'], 'right'); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
| 219 | - <option value="inline"<?php selected($field['label'], 'inline'); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
| 220 | - <option value="none"<?php selected($field['label'], 'none'); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
| 221 | - <option value="hidden"<?php selected($field['label'], 'hidden'); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
| 215 | + <option value=""<?php selected( $field['label'], '' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 216 | + <option value="top"<?php selected( $field['label'], 'top' ); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
| 217 | + <option value="left"<?php selected( $field['label'], 'left' ); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
| 218 | + <option value="right"<?php selected( $field['label'], 'right' ); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
| 219 | + <option value="inline"<?php selected( $field['label'], 'inline' ); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
| 220 | + <option value="none"<?php selected( $field['label'], 'none' ); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
| 221 | + <option value="hidden"<?php selected( $field['label'], 'hidden' ); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
| 222 | 222 | </select> |
| 223 | 223 | </td> |
| 224 | 224 | </tr> |
@@ -250,8 +250,8 @@ discard block |
||
| 250 | 250 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Set the size of the captcha field. The compact option is best if your form is in a small area.', 'formidable' ) ?>" ></span> |
| 251 | 251 | </td> |
| 252 | 252 | <td><select name="field_options[captcha_size_<?php echo esc_attr( $field['id'] ) ?>]"> |
| 253 | - <option value="default"<?php selected($field['captcha_size'], 'default'); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 254 | - <option value="compact"<?php selected($field['captcha_size'], 'compact'); ?>><?php _e( 'Compact', 'formidable' ) ?></option> |
|
| 253 | + <option value="default"<?php selected( $field['captcha_size'], 'default' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 254 | + <option value="compact"<?php selected( $field['captcha_size'], 'compact' ); ?>><?php _e( 'Compact', 'formidable' ) ?></option> |
|
| 255 | 255 | </select> |
| 256 | 256 | </td> |
| 257 | 257 | </tr> |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | do_action( 'frm_field_options_form', $field, $display, $values ); |
| 263 | 263 | |
| 264 | 264 | if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
| 265 | - <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'; ?>"> |
|
| 265 | + <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'; ?>"> |
|
| 266 | 266 | <td colspan="2"> |
| 267 | 267 | <div class="menu-settings"> |
| 268 | 268 | <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3> |
@@ -326,4 +326,4 @@ discard block |
||
| 326 | 326 | <?php |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | -unset($display); |
|
| 329 | +unset( $display ); |
|
@@ -9,9 +9,9 @@ discard block |
||
| 9 | 9 | <div id="post-body-content"> |
| 10 | 10 | <?php |
| 11 | 11 | if ( ! $values['is_template'] ) { |
| 12 | - FrmAppController::get_form_nav($id, true, 'hide'); |
|
| 12 | + FrmAppController::get_form_nav( $id, true, 'hide' ); |
|
| 13 | 13 | } |
| 14 | - require(FrmAppHelper::plugin_path() .'/classes/views/shared/errors.php'); |
|
| 14 | + require( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); |
|
| 15 | 15 | |
| 16 | 16 | ?> |
| 17 | 17 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | <input type="hidden" name="action" value="create" /> |
| 23 | 23 | <input type="hidden" name="id" id="form_id" value="<?php echo (int) $id; ?>" /> |
| 24 | 24 | |
| 25 | - <?php require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/form.php'); ?> |
|
| 25 | + <?php require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/form.php' ); ?> |
|
| 26 | 26 | |
| 27 | 27 | <p> |
| 28 | 28 | <input type="button" value="<?php esc_attr_e( 'Create', 'formidable' ) ?>" class="frm_submit_<?php echo ( isset( $values['ajax_load'] ) && $values['ajax_load'] ) ? '' : 'no_'; ?>ajax button-primary" /> |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | </div> |
| 34 | 34 | </div> |
| 35 | - <?php require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field_links.php'); ?> |
|
| 35 | + <?php require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field_links.php' ); ?> |
|
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | </div> |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmEntryValidate { |
| 4 | - public static function validate( $values, $exclude = false ) { |
|
| 5 | - global $wpdb; |
|
| 4 | + public static function validate( $values, $exclude = false ) { |
|
| 5 | + global $wpdb; |
|
| 6 | 6 | |
| 7 | - FrmEntry::sanitize_entry_post( $values ); |
|
| 8 | - $errors = array(); |
|
| 7 | + FrmEntry::sanitize_entry_post( $values ); |
|
| 8 | + $errors = array(); |
|
| 9 | 9 | |
| 10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 11 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 12 | - return $errors; |
|
| 13 | - } |
|
| 10 | + if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 11 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 12 | + return $errors; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
| 16 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 17 | - } |
|
| 16 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 20 | - $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
| 21 | - } |
|
| 19 | + if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 20 | + $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 23 | + $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 24 | 24 | // Don't get subfields |
| 25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
| 26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,46 +28,46 @@ discard block |
||
| 28 | 28 | $where['fi.type not'] = $exclude; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 31 | + $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 32 | 32 | |
| 33 | - // Pass exclude value to validate_field function so it can be used for repeating sections |
|
| 34 | - $args = array( 'exclude' => $exclude ); |
|
| 33 | + // Pass exclude value to validate_field function so it can be used for repeating sections |
|
| 34 | + $args = array( 'exclude' => $exclude ); |
|
| 35 | 35 | |
| 36 | - foreach ( $posted_fields as $posted_field ) { |
|
| 37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | - unset($posted_field); |
|
| 39 | - } |
|
| 36 | + foreach ( $posted_fields as $posted_field ) { |
|
| 37 | + self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | + unset($posted_field); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - // check for spam |
|
| 42 | - self::spam_check( $exclude, $values, $errors ); |
|
| 41 | + // check for spam |
|
| 42 | + self::spam_check( $exclude, $values, $errors ); |
|
| 43 | 43 | |
| 44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 45 | 45 | |
| 46 | - return $errors; |
|
| 47 | - } |
|
| 46 | + return $errors; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 50 | - $defaults = array( |
|
| 51 | - 'id' => $posted_field->id, |
|
| 52 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 53 | - 'key_pointer' => '', // the pointer in the posted array |
|
| 54 | - 'exclude' => array(), // exclude these field types from validation |
|
| 55 | - ); |
|
| 56 | - $args = wp_parse_args( $args, $defaults ); |
|
| 49 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 50 | + $defaults = array( |
|
| 51 | + 'id' => $posted_field->id, |
|
| 52 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 53 | + 'key_pointer' => '', // the pointer in the posted array |
|
| 54 | + 'exclude' => array(), // exclude these field types from validation |
|
| 55 | + ); |
|
| 56 | + $args = wp_parse_args( $args, $defaults ); |
|
| 57 | 57 | |
| 58 | - if ( empty($args['parent_field_id']) ) { |
|
| 58 | + if ( empty($args['parent_field_id']) ) { |
|
| 59 | 59 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
| 60 | - } else { |
|
| 61 | - // value is from a nested form |
|
| 62 | - $value = $values; |
|
| 63 | - } |
|
| 60 | + } else { |
|
| 61 | + // value is from a nested form |
|
| 62 | + $value = $values; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - // Check for values in "Other" fields |
|
| 66 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 65 | + // Check for values in "Other" fields |
|
| 66 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 67 | 67 | |
| 68 | - if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
| 69 | - $value = ''; |
|
| 70 | - } |
|
| 68 | + if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
| 69 | + $value = ''; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | // Check for an array with only one value |
| 73 | 73 | // Don't reset values in "Other" fields because array keys need to be preserved |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | $value = reset($value); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 78 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 79 | 79 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
| 80 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 81 | - $_POST['item_name'] = $value; |
|
| 82 | - } |
|
| 80 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 81 | + $_POST['item_name'] = $value; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | if ( $value != '' ) { |
| 85 | 85 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -88,42 +88,42 @@ discard block |
||
| 88 | 88 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 91 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 92 | 92 | |
| 93 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 93 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
| 94 | 94 | |
| 95 | - $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
| 95 | + $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
| 96 | 96 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
| 100 | 100 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
| 101 | - return; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - if ( trim($value) == 'http://' ) { |
|
| 105 | - $value = ''; |
|
| 106 | - } else { |
|
| 107 | - $value = esc_url_raw( $value ); |
|
| 108 | - $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - //validate the url format |
|
| 112 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + if ( trim($value) == 'http://' ) { |
|
| 105 | + $value = ''; |
|
| 106 | + } else { |
|
| 107 | + $value = esc_url_raw( $value ); |
|
| 108 | + $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + //validate the url format |
|
| 112 | + if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 113 | 113 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 114 | - } |
|
| 115 | - } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
| 118 | - if ( $value == '' || $field->type != 'email' ) { |
|
| 119 | - return; |
|
| 120 | - } |
|
| 118 | + if ( $value == '' || $field->type != 'email' ) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - //validate the email format |
|
| 123 | - if ( ! is_email($value) ) { |
|
| 122 | + //validate the email format |
|
| 123 | + if ( ! is_email($value) ) { |
|
| 124 | 124 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 125 | - } |
|
| 126 | - } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
| 129 | 129 | //validate the number format |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public static function validate_recaptcha( &$errors, $field, $args ) { |
| 203 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 204 | - return; |
|
| 205 | - } |
|
| 203 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | $frm_settings = FrmAppHelper::get_settings(); |
| 208 | 208 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -210,53 +210,53 @@ discard block |
||
| 210 | 210 | return; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 214 | - // If captcha is missing, check if it was already verified |
|
| 213 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 214 | + // If captcha is missing, check if it was already verified |
|
| 215 | 215 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 216 | - // There was no captcha submitted |
|
| 216 | + // There was no captcha submitted |
|
| 217 | 217 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
| 218 | - } |
|
| 219 | - return; |
|
| 220 | - } |
|
| 218 | + } |
|
| 219 | + return; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - $arg_array = array( |
|
| 223 | - 'body' => array( |
|
| 222 | + $arg_array = array( |
|
| 223 | + 'body' => array( |
|
| 224 | 224 | 'secret' => $frm_settings->privkey, |
| 225 | 225 | 'response' => $_POST['g-recaptcha-response'], |
| 226 | 226 | 'remoteip' => FrmAppHelper::get_ip_address(), |
| 227 | 227 | ), |
| 228 | 228 | ); |
| 229 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 230 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 229 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 230 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 231 | 231 | |
| 232 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 233 | - // What happens when the CAPTCHA was entered incorrectly |
|
| 232 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 233 | + // What happens when the CAPTCHA was entered incorrectly |
|
| 234 | 234 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
| 235 | - } |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * check for spam |
|
| 240 | - * @param boolean $exclude |
|
| 241 | - * @param array $values |
|
| 242 | - * @param array $errors by reference |
|
| 243 | - */ |
|
| 244 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
| 245 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 246 | - // only check spam if there are no other errors |
|
| 247 | - return; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - if ( self::is_akismet_spam( $values ) ) { |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * check for spam |
|
| 240 | + * @param boolean $exclude |
|
| 241 | + * @param array $values |
|
| 242 | + * @param array $errors by reference |
|
| 243 | + */ |
|
| 244 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
| 245 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 246 | + // only check spam if there are no other errors |
|
| 247 | + return; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + if ( self::is_akismet_spam( $values ) ) { |
|
| 251 | 251 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
| 252 | 252 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
| 253 | 253 | } |
| 254 | - } |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - if ( self::blacklist_check( $values ) ) { |
|
| 257 | - $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
| 258 | - } |
|
| 259 | - } |
|
| 256 | + if ( self::blacklist_check( $values ) ) { |
|
| 257 | + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | 261 | private static function is_akismet_spam( $values ) { |
| 262 | 262 | global $wpcom_api_key; |
@@ -268,54 +268,54 @@ discard block |
||
| 268 | 268 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - public static function blacklist_check( $values ) { |
|
| 272 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 273 | - return false; |
|
| 274 | - } |
|
| 271 | + public static function blacklist_check( $values ) { |
|
| 272 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 273 | + return false; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 276 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 277 | 277 | |
| 278 | - if ( empty( $mod_keys ) ) { |
|
| 279 | - return false; |
|
| 280 | - } |
|
| 278 | + if ( empty( $mod_keys ) ) { |
|
| 279 | + return false; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 282 | + $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 283 | 283 | |
| 284 | 284 | if ( empty($content) ) { |
| 285 | - return false; |
|
| 285 | + return false; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - $words = explode( "\n", $mod_keys ); |
|
| 288 | + $words = explode( "\n", $mod_keys ); |
|
| 289 | 289 | |
| 290 | - foreach ( (array) $words as $word ) { |
|
| 291 | - $word = trim( $word ); |
|
| 290 | + foreach ( (array) $words as $word ) { |
|
| 291 | + $word = trim( $word ); |
|
| 292 | 292 | |
| 293 | - if ( empty($word) ) { |
|
| 294 | - continue; |
|
| 295 | - } |
|
| 293 | + if ( empty($word) ) { |
|
| 294 | + continue; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 298 | - return true; |
|
| 299 | - } |
|
| 300 | - } |
|
| 297 | + if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 298 | + return true; |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - return false; |
|
| 303 | - } |
|
| 302 | + return false; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - /** |
|
| 306 | - * Check entries for spam |
|
| 307 | - * |
|
| 308 | - * @return boolean true if is spam |
|
| 309 | - */ |
|
| 310 | - public static function akismet( $values ) { |
|
| 311 | - $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 305 | + /** |
|
| 306 | + * Check entries for spam |
|
| 307 | + * |
|
| 308 | + * @return boolean true if is spam |
|
| 309 | + */ |
|
| 310 | + public static function akismet( $values ) { |
|
| 311 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 312 | 312 | |
| 313 | 313 | if ( empty( $content ) ) { |
| 314 | - return false; |
|
| 314 | + return false; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $datas = array(); |
|
| 318 | - self::parse_akismet_array( $datas, $content ); |
|
| 317 | + $datas = array(); |
|
| 318 | + self::parse_akismet_array( $datas, $content ); |
|
| 319 | 319 | |
| 320 | 320 | $query_string = ''; |
| 321 | 321 | foreach ( $datas as $key => $data ) { |
@@ -323,35 +323,35 @@ discard block |
||
| 323 | 323 | unset( $key, $data ); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 326 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 327 | 327 | |
| 328 | 328 | return ( is_array( $response ) && $response[1] == 'true' ); |
| 329 | - } |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * @since 2.0 |
|
| 333 | - * @param string $content |
|
| 334 | - */ |
|
| 335 | - private static function parse_akismet_array( &$datas, $content ) { |
|
| 336 | - $datas['blog'] = FrmAppHelper::site_url(); |
|
| 337 | - $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * @since 2.0 |
|
| 333 | + * @param string $content |
|
| 334 | + */ |
|
| 335 | + private static function parse_akismet_array( &$datas, $content ) { |
|
| 336 | + $datas['blog'] = FrmAppHelper::site_url(); |
|
| 337 | + $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
| 338 | 338 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
| 339 | 339 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
| 340 | - $datas['comment_type'] = 'formidable'; |
|
| 341 | - $datas['comment_content'] = $content; |
|
| 340 | + $datas['comment_type'] = 'formidable'; |
|
| 341 | + $datas['comment_content'] = $content; |
|
| 342 | 342 | |
| 343 | - if ( $permalink = get_permalink() ) { |
|
| 344 | - $datas['permalink'] = $permalink; |
|
| 345 | - } |
|
| 343 | + if ( $permalink = get_permalink() ) { |
|
| 344 | + $datas['permalink'] = $permalink; |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | - foreach ( $_SERVER as $key => $value ) { |
|
| 347 | + foreach ( $_SERVER as $key => $value ) { |
|
| 348 | 348 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
| 349 | 349 | $datas[ $key ] = wp_strip_all_tags( $value ); |
| 350 | - } else { |
|
| 350 | + } else { |
|
| 351 | 351 | $datas[ $key ] = ''; |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - unset($key, $value); |
|
| 355 | - } |
|
| 356 | - } |
|
| 354 | + unset($key, $value); |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | 357 | } |