@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmStylesController { |
| 4 | - public static $post_type = 'frm_styles'; |
|
| 5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
| 4 | + public static $post_type = 'frm_styles'; |
|
| 5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | 6 | |
| 7 | - public static function load_pro_hooks() { |
|
| 8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | - FrmProStylesController::load_pro_hooks(); |
|
| 10 | - } |
|
| 11 | - } |
|
| 7 | + public static function load_pro_hooks() { |
|
| 8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | + FrmProStylesController::load_pro_hooks(); |
|
| 10 | + } |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public static function register_post_types() { |
|
| 13 | + public static function register_post_types() { |
|
| 14 | 14 | register_post_type( |
| 15 | 15 | self::$post_type, |
| 16 | 16 | array( |
@@ -41,18 +41,18 @@ discard block |
||
| 41 | 41 | ), |
| 42 | 42 | ) |
| 43 | 43 | ); |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public static function menu() { |
|
| 46 | + public static function menu() { |
|
| 47 | 47 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | public static function admin_init() { |
| 51 | 51 | if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) { |
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - self::load_pro_hooks(); |
|
| 55 | + self::load_pro_hooks(); |
|
| 56 | 56 | |
| 57 | 57 | $style_tab = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 58 | 58 | if ( $style_tab == 'manage' || $style_tab == 'custom_css' ) { |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) ); |
| 66 | 66 | |
| 67 | 67 | $style = apply_filters( 'frm_style_head', false ); |
| 68 | - if ( $style ) { |
|
| 68 | + if ( $style ) { |
|
| 69 | 69 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
| 70 | - } |
|
| 71 | - } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | public static function enqueue_css( $register = 'enqueue', $force = false ) { |
| 74 | 74 | global $frm_vars; |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | public static function load_styler( $style, $message = '' ) { |
| 222 | - global $frm_settings; |
|
| 222 | + global $frm_settings; |
|
| 223 | 223 | |
| 224 | - $frm_style = new FrmStyle(); |
|
| 225 | - $styles = $frm_style->get_all(); |
|
| 224 | + $frm_style = new FrmStyle(); |
|
| 225 | + $styles = $frm_style->get_all(); |
|
| 226 | 226 | |
| 227 | 227 | if ( is_numeric( $style ) ) { |
| 228 | 228 | $style = $styles[ $style ]; |
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | $style = $frm_style->get_default_style( $styles ); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - self::add_meta_boxes(); |
|
| 233 | + self::add_meta_boxes(); |
|
| 234 | 234 | |
| 235 | 235 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
| 236 | - } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | 238 | /** |
| 239 | 239 | * @param string $message |
@@ -251,31 +251,31 @@ discard block |
||
| 251 | 251 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - private static function manage_styles() { |
|
| 254 | + private static function manage_styles() { |
|
| 255 | 255 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
| 256 | 256 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
| 257 | - return self::manage(); |
|
| 258 | - } |
|
| 257 | + return self::manage(); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - global $wpdb; |
|
| 260 | + global $wpdb; |
|
| 261 | 261 | |
| 262 | 262 | $forms = FrmForm::get_published_forms(); |
| 263 | - foreach ( $forms as $form ) { |
|
| 264 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 265 | - continue; |
|
| 266 | - } |
|
| 263 | + foreach ( $forms as $form ) { |
|
| 264 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 265 | + continue; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 268 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 269 | 269 | |
| 270 | 270 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 271 | 271 | unset( $form ); |
| 272 | - } |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 274 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 275 | 275 | return self::manage( $message, $forms ); |
| 276 | - } |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - public static function custom_css( $message = '', $style = null ) { |
|
| 278 | + public static function custom_css( $message = '', $style = null ) { |
|
| 279 | 279 | if ( function_exists( 'wp_enqueue_code_editor' ) ) { |
| 280 | 280 | $id = 'frm_codemirror_box'; |
| 281 | 281 | $settings = wp_enqueue_code_editor( |
@@ -317,41 +317,41 @@ discard block |
||
| 317 | 317 | return self::custom_css( $message ); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - public static function route() { |
|
| 320 | + public static function route() { |
|
| 321 | 321 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 322 | 322 | |
| 323 | - switch ( $action ) { |
|
| 324 | - case 'edit': |
|
| 325 | - case 'save': |
|
| 326 | - case 'manage': |
|
| 327 | - case 'manage_styles': |
|
| 328 | - case 'custom_css': |
|
| 329 | - case 'save_css': |
|
| 323 | + switch ( $action ) { |
|
| 324 | + case 'edit': |
|
| 325 | + case 'save': |
|
| 326 | + case 'manage': |
|
| 327 | + case 'manage_styles': |
|
| 328 | + case 'custom_css': |
|
| 329 | + case 'save_css': |
|
| 330 | 330 | return self::$action(); |
| 331 | - default: |
|
| 332 | - do_action( 'frm_style_action_route', $action ); |
|
| 333 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 334 | - return; |
|
| 335 | - } |
|
| 331 | + default: |
|
| 332 | + do_action( 'frm_style_action_route', $action ); |
|
| 333 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 334 | + return; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 338 | - return self::$action(); |
|
| 339 | - } |
|
| 337 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 338 | + return self::$action(); |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - return self::edit(); |
|
| 342 | - } |
|
| 343 | - } |
|
| 341 | + return self::edit(); |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - public static function reset_styling() { |
|
| 345 | + public static function reset_styling() { |
|
| 346 | 346 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 347 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 347 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 348 | 348 | |
| 349 | - $frm_style = new FrmStyle(); |
|
| 350 | - $defaults = $frm_style->get_defaults(); |
|
| 349 | + $frm_style = new FrmStyle(); |
|
| 350 | + $defaults = $frm_style->get_defaults(); |
|
| 351 | 351 | |
| 352 | - echo json_encode( $defaults ); |
|
| 353 | - wp_die(); |
|
| 354 | - } |
|
| 352 | + echo json_encode( $defaults ); |
|
| 353 | + wp_die(); |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | 356 | public static function change_styling() { |
| 357 | 357 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
@@ -366,21 +366,21 @@ discard block |
||
| 366 | 366 | wp_die(); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - private static function add_meta_boxes() { |
|
| 370 | - |
|
| 371 | - // setup meta boxes |
|
| 372 | - $meta_boxes = array( |
|
| 373 | - 'general' => __( 'General', 'formidable' ), |
|
| 374 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 375 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 376 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 377 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 378 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 379 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 380 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 381 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 382 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 383 | - ); |
|
| 369 | + private static function add_meta_boxes() { |
|
| 370 | + |
|
| 371 | + // setup meta boxes |
|
| 372 | + $meta_boxes = array( |
|
| 373 | + 'general' => __( 'General', 'formidable' ), |
|
| 374 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 375 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 376 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 377 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 378 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 379 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 380 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 381 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 382 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 383 | + ); |
|
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | 386 | * Add custom boxes to the styling settings |
@@ -412,18 +412,18 @@ discard block |
||
| 412 | 412 | $file_name = apply_filters( 'frm_style_settings_' . $sec['args'], $file_name ); |
| 413 | 413 | |
| 414 | 414 | include( $file_name ); |
| 415 | - } |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | - public static function load_css() { |
|
| 417 | + public static function load_css() { |
|
| 418 | 418 | header( 'Content-type: text/css' ); |
| 419 | 419 | |
| 420 | - $frm_style = new FrmStyle(); |
|
| 421 | - $defaults = $frm_style->get_defaults(); |
|
| 420 | + $frm_style = new FrmStyle(); |
|
| 421 | + $defaults = $frm_style->get_defaults(); |
|
| 422 | 422 | $style = ''; |
| 423 | 423 | |
| 424 | 424 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
| 425 | - wp_die(); |
|
| 426 | - } |
|
| 425 | + wp_die(); |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | 428 | public static function load_saved_css() { |
| 429 | 429 | $css = get_transient( 'frmpro_css' ); |
@@ -432,49 +432,49 @@ discard block |
||
| 432 | 432 | wp_die(); |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - /** |
|
| 436 | - * Check if the Formidable styling should be loaded, |
|
| 437 | - * then enqueue it for the footer |
|
| 438 | - * @since 2.0 |
|
| 439 | - */ |
|
| 440 | - public static function enqueue_style() { |
|
| 441 | - global $frm_vars; |
|
| 442 | - |
|
| 443 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 444 | - // the CSS has already been loaded |
|
| 445 | - return; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 449 | - if ( $frm_settings->load_style != 'none' ) { |
|
| 450 | - wp_enqueue_style( 'formidable' ); |
|
| 451 | - $frm_vars['css_loaded'] = true; |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - // Get the stylesheets for the form settings page |
|
| 456 | - public static function get_style_opts() { |
|
| 457 | - $frm_style = new FrmStyle(); |
|
| 458 | - $styles = $frm_style->get_all(); |
|
| 459 | - |
|
| 460 | - return $styles; |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - public static function get_form_style( $form = 'default' ) { |
|
| 464 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
| 465 | - |
|
| 466 | - if ( empty( $style ) || 1 == $style ) { |
|
| 467 | - $style = 'default'; |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - $frm_style = new FrmStyle( $style ); |
|
| 471 | - return $frm_style->get_one(); |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * @param string $class |
|
| 476 | - * @param string $style |
|
| 477 | - */ |
|
| 435 | + /** |
|
| 436 | + * Check if the Formidable styling should be loaded, |
|
| 437 | + * then enqueue it for the footer |
|
| 438 | + * @since 2.0 |
|
| 439 | + */ |
|
| 440 | + public static function enqueue_style() { |
|
| 441 | + global $frm_vars; |
|
| 442 | + |
|
| 443 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 444 | + // the CSS has already been loaded |
|
| 445 | + return; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 449 | + if ( $frm_settings->load_style != 'none' ) { |
|
| 450 | + wp_enqueue_style( 'formidable' ); |
|
| 451 | + $frm_vars['css_loaded'] = true; |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + // Get the stylesheets for the form settings page |
|
| 456 | + public static function get_style_opts() { |
|
| 457 | + $frm_style = new FrmStyle(); |
|
| 458 | + $styles = $frm_style->get_all(); |
|
| 459 | + |
|
| 460 | + return $styles; |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + public static function get_form_style( $form = 'default' ) { |
|
| 464 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
| 465 | + |
|
| 466 | + if ( empty( $style ) || 1 == $style ) { |
|
| 467 | + $style = 'default'; |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + $frm_style = new FrmStyle( $style ); |
|
| 471 | + return $frm_style->get_one(); |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * @param string $class |
|
| 476 | + * @param string $style |
|
| 477 | + */ |
|
| 478 | 478 | public static function get_form_style_class( $class, $style ) { |
| 479 | 479 | if ( 1 == $style ) { |
| 480 | 480 | $style = 'default'; |
@@ -504,9 +504,9 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - /** |
|
| 508 | - * @param string $val |
|
| 509 | - */ |
|
| 507 | + /** |
|
| 508 | + * @param string $val |
|
| 509 | + */ |
|
| 510 | 510 | public static function get_style_val( $val, $form = 'default' ) { |
| 511 | 511 | $style = self::get_form_style( $form ); |
| 512 | 512 | if ( $style && isset( $style->post_content[ $val ] ) ) { |
@@ -516,72 +516,72 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | public static function show_entry_styles( $default_styles ) { |
| 518 | 518 | $frm_style = new FrmStyle( 'default' ); |
| 519 | - $style = $frm_style->get_one(); |
|
| 520 | - |
|
| 521 | - if ( ! $style ) { |
|
| 522 | - return $default_styles; |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - foreach ( $default_styles as $name => $val ) { |
|
| 526 | - $setting = $name; |
|
| 527 | - if ( 'border_width' == $name ) { |
|
| 528 | - $setting = 'field_border_width'; |
|
| 529 | - } else if ( 'alt_bg_color' == $name ) { |
|
| 530 | - $setting = 'bg_color_active'; |
|
| 531 | - } |
|
| 532 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 519 | + $style = $frm_style->get_one(); |
|
| 520 | + |
|
| 521 | + if ( ! $style ) { |
|
| 522 | + return $default_styles; |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + foreach ( $default_styles as $name => $val ) { |
|
| 526 | + $setting = $name; |
|
| 527 | + if ( 'border_width' == $name ) { |
|
| 528 | + $setting = 'field_border_width'; |
|
| 529 | + } else if ( 'alt_bg_color' == $name ) { |
|
| 530 | + $setting = 'bg_color_active'; |
|
| 531 | + } |
|
| 532 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 533 | 533 | unset( $name, $val ); |
| 534 | - } |
|
| 534 | + } |
|
| 535 | 535 | |
| 536 | - return $default_styles; |
|
| 537 | - } |
|
| 536 | + return $default_styles; |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | 539 | public static function &important_style( $important, $field ) { |
| 540 | 540 | $important = self::get_style_val( 'important_style', $field['form_id'] ); |
| 541 | - return $important; |
|
| 542 | - } |
|
| 541 | + return $important; |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | - /** |
|
| 545 | - * Fallback for WP < 3.6 |
|
| 546 | - */ |
|
| 547 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 548 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 549 | - return do_accordion_sections( $screen, $context, $object ); |
|
| 550 | - } |
|
| 544 | + /** |
|
| 545 | + * Fallback for WP < 3.6 |
|
| 546 | + */ |
|
| 547 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 548 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 549 | + return do_accordion_sections( $screen, $context, $object ); |
|
| 550 | + } |
|
| 551 | 551 | |
| 552 | - global $wp_meta_boxes; |
|
| 552 | + global $wp_meta_boxes; |
|
| 553 | 553 | |
| 554 | - $screen = 'formidable_page_formidable-styles'; |
|
| 555 | - $screen = convert_to_screen( $screen ); |
|
| 554 | + $screen = 'formidable_page_formidable-styles'; |
|
| 555 | + $screen = convert_to_screen( $screen ); |
|
| 556 | 556 | |
| 557 | - $page = $screen->id; |
|
| 557 | + $page = $screen->id; |
|
| 558 | 558 | |
| 559 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 560 | - ?> |
|
| 559 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
| 560 | + ?> |
|
| 561 | 561 | <div id="side-sortables" class="accordion-container"> |
| 562 | 562 | <?php |
| 563 | - $i = 0; |
|
| 564 | - $first_open = false; |
|
| 565 | - do { |
|
| 563 | + $i = 0; |
|
| 564 | + $first_open = false; |
|
| 565 | + do { |
|
| 566 | 566 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
| 567 | 567 | break; |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 571 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 572 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 573 | - if ( false == $box || ! $box['title'] ) { |
|
| 574 | - continue; |
|
| 570 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 571 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 572 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 573 | + if ( false == $box || ! $box['title'] ) { |
|
| 574 | + continue; |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - $i++; |
|
| 578 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 577 | + $i++; |
|
| 578 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 579 | 579 | |
| 580 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 581 | - $first_open = true; |
|
| 582 | - } |
|
| 580 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 581 | + $first_open = true; |
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | - ?> |
|
| 584 | + ?> |
|
| 585 | 585 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
| 586 | 586 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ); ?>"><br/></div> |
| 587 | 587 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -592,13 +592,13 @@ discard block |
||
| 592 | 592 | </div><!-- .accordion-section-content --> |
| 593 | 593 | </div><!-- .postbox --> |
| 594 | 594 | <?php |
| 595 | - } |
|
| 596 | - } |
|
| 597 | - } |
|
| 598 | - } while ( 0 ); |
|
| 599 | - ?> |
|
| 595 | + } |
|
| 596 | + } |
|
| 597 | + } |
|
| 598 | + } while ( 0 ); |
|
| 599 | + ?> |
|
| 600 | 600 | </div><!-- .accordion-container --> |
| 601 | 601 | <?php |
| 602 | - return $i; |
|
| 603 | - } |
|
| 602 | + return $i; |
|
| 603 | + } |
|
| 604 | 604 | } |
@@ -2,89 +2,89 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmHooksController { |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Trigger plugin-wide hook loading |
|
| 7 | - */ |
|
| 8 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 9 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 10 | - |
|
| 11 | - $trigger_hooks = $hooks; |
|
| 12 | - $hooks = (array) $hooks; |
|
| 13 | - |
|
| 14 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
| 15 | - if ( is_admin() ) { |
|
| 16 | - $hooks[] = 'load_admin_hooks'; |
|
| 17 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 18 | - $hooks[] = 'load_ajax_hooks'; |
|
| 19 | - $hooks[] = 'load_form_hooks'; |
|
| 20 | - } |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - if ( is_multisite() ) { |
|
| 24 | - $hooks[] = 'load_multisite_hooks'; |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - // Make sure the hooks are only triggered once |
|
| 28 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 29 | - } |
|
| 30 | - unset( $trigger_hooks ); |
|
| 31 | - |
|
| 32 | - // Instansiate Controllers |
|
| 33 | - foreach ( $controllers as $c ) { |
|
| 34 | - foreach ( $hooks as $hook ) { |
|
| 5 | + /** |
|
| 6 | + * Trigger plugin-wide hook loading |
|
| 7 | + */ |
|
| 8 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 9 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 10 | + |
|
| 11 | + $trigger_hooks = $hooks; |
|
| 12 | + $hooks = (array) $hooks; |
|
| 13 | + |
|
| 14 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
| 15 | + if ( is_admin() ) { |
|
| 16 | + $hooks[] = 'load_admin_hooks'; |
|
| 17 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 18 | + $hooks[] = 'load_ajax_hooks'; |
|
| 19 | + $hooks[] = 'load_form_hooks'; |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + if ( is_multisite() ) { |
|
| 24 | + $hooks[] = 'load_multisite_hooks'; |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + // Make sure the hooks are only triggered once |
|
| 28 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 29 | + } |
|
| 30 | + unset( $trigger_hooks ); |
|
| 31 | + |
|
| 32 | + // Instansiate Controllers |
|
| 33 | + foreach ( $controllers as $c ) { |
|
| 34 | + foreach ( $hooks as $hook ) { |
|
| 35 | 35 | call_user_func( array( $c, $hook ) ); |
| 36 | 36 | unset( $hook ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | unset( $c ); |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public static function trigger_load_form_hooks() { |
|
| 44 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
| 45 | - } |
|
| 43 | + public static function trigger_load_form_hooks() { |
|
| 44 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | public static function load_hooks() { |
| 48 | 48 | add_action( 'rest_api_init', 'FrmAppController::create_rest_routes', 0 ); |
| 49 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 49 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 50 | 50 | add_filter( 'widget_text', 'do_shortcode' ); |
| 51 | 51 | |
| 52 | - // Entries controller |
|
| 53 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 54 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 52 | + // Entries controller |
|
| 53 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 54 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 55 | 55 | |
| 56 | - // Form Actions Controller |
|
| 57 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 56 | + // Form Actions Controller |
|
| 57 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 58 | 58 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
| 59 | 59 | |
| 60 | - // Forms Controller |
|
| 61 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 60 | + // Forms Controller |
|
| 61 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 62 | 62 | add_action( 'init', 'FrmFormsController::front_head' ); |
| 63 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 64 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 65 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 63 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 64 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 65 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 66 | 66 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
| 67 | 67 | |
| 68 | 68 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
| 69 | 69 | |
| 70 | - // Form Shortcodes |
|
| 71 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 70 | + // Form Shortcodes |
|
| 71 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 72 | 72 | |
| 73 | - // Styles Controller |
|
| 74 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 75 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 76 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 77 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 73 | + // Styles Controller |
|
| 74 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 75 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 76 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 77 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 78 | 78 | |
| 79 | 79 | //Simple Blocks Controller |
| 80 | 80 | add_action( 'init', 'FrmSimpleBlocksController::register_simple_form_block' ); |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | public static function load_admin_hooks() { |
| 84 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 84 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 85 | 85 | add_filter( 'admin_body_class', 'FrmAppController::add_admin_class', 999 ); |
| 86 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 87 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 86 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 87 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 88 | 88 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
| 89 | 89 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
| 90 | 90 | add_filter( 'admin_footer_text', 'FrmAppController::set_footer_text' ); |
@@ -95,120 +95,120 @@ discard block |
||
| 95 | 95 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
| 96 | 96 | add_filter( 'pre_set_site_transient_update_plugins', 'FrmAddonsController::check_update' ); |
| 97 | 97 | |
| 98 | - // Entries Controller |
|
| 99 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 100 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 101 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 102 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 103 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 104 | - |
|
| 105 | - // Form Actions Controller |
|
| 106 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 107 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 108 | - } |
|
| 109 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 110 | - |
|
| 111 | - // Forms Controller |
|
| 112 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 113 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 114 | - |
|
| 115 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 116 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 98 | + // Entries Controller |
|
| 99 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 100 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 101 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 102 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 103 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 104 | + |
|
| 105 | + // Form Actions Controller |
|
| 106 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 107 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 108 | + } |
|
| 109 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 110 | + |
|
| 111 | + // Forms Controller |
|
| 112 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 113 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 114 | + |
|
| 115 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 116 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 117 | 117 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 118 | 118 | add_action( 'et_pb_admin_excluded_shortcodes', 'FrmFormsController::prevent_divi_conflict' ); |
| 119 | 119 | |
| 120 | - // Forms Model |
|
| 121 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 120 | + // Forms Model |
|
| 121 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 122 | 122 | |
| 123 | - // Settings Controller |
|
| 124 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 125 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 123 | + // Settings Controller |
|
| 124 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 125 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 126 | 126 | add_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' ); |
| 127 | 127 | add_action( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' ); |
| 128 | 128 | |
| 129 | - // Styles Controller |
|
| 130 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 131 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 129 | + // Styles Controller |
|
| 130 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 131 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 132 | 132 | |
| 133 | - // XML Controller |
|
| 134 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 133 | + // XML Controller |
|
| 134 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 135 | 135 | |
| 136 | 136 | // Simple Blocks Controller |
| 137 | 137 | add_action( 'enqueue_block_editor_assets', 'FrmSimpleBlocksController::block_editor_assets' ); |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | public static function load_ajax_hooks() { |
| 141 | 141 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
| 142 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 143 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 142 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 143 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 144 | 144 | |
| 145 | 145 | // Addons |
| 146 | 146 | add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
| 147 | 147 | add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
| 148 | 148 | add_action( 'wp_ajax_frm_install_addon', 'FrmAddonsController::ajax_install_addon' ); |
| 149 | 149 | |
| 150 | - // Fields Controller |
|
| 151 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 152 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 153 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 154 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 155 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 156 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 157 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 158 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 159 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 160 | - |
|
| 161 | - // Form Actions Controller |
|
| 162 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 163 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 164 | - |
|
| 165 | - // Forms Controller |
|
| 150 | + // Fields Controller |
|
| 151 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 152 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 153 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 154 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 155 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 156 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 157 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 158 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 159 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 160 | + |
|
| 161 | + // Form Actions Controller |
|
| 162 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 163 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 164 | + |
|
| 165 | + // Forms Controller |
|
| 166 | 166 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
| 167 | 167 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
| 168 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 169 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 170 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 171 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 168 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 169 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 170 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 171 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 172 | 172 | |
| 173 | 173 | // Settings |
| 174 | 174 | add_action( 'wp_ajax_frm_lite_settings_upgrade', 'FrmSettingsController::settings_cta_dismiss' ); |
| 175 | 175 | |
| 176 | - // Styles Controller |
|
| 177 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 178 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 179 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 180 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 176 | + // Styles Controller |
|
| 177 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 178 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 179 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 180 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 181 | 181 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 182 | 182 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 183 | 183 | |
| 184 | - // XML Controller |
|
| 184 | + // XML Controller |
|
| 185 | 185 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
| 186 | 186 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
| 187 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 188 | - } |
|
| 187 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | 190 | public static function load_form_hooks() { |
| 191 | - // Fields Controller |
|
| 192 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 193 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 194 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 195 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 191 | + // Fields Controller |
|
| 192 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 193 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 194 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 195 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 196 | 196 | |
| 197 | 197 | // Forms Controller |
| 198 | 198 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
| 199 | 199 | |
| 200 | - // Styles Controller |
|
| 201 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 202 | - } |
|
| 200 | + // Styles Controller |
|
| 201 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | public static function load_view_hooks() { |
| 205 | - // Hooks go here when a view is loaded |
|
| 206 | - } |
|
| 205 | + // Hooks go here when a view is loaded |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | public static function load_multisite_hooks() { |
| 209 | 209 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
| 210 | 210 | |
| 211 | - // drop tables when mu site is deleted |
|
| 212 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 213 | - } |
|
| 211 | + // drop tables when mu site is deleted |
|
| 212 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 213 | + } |
|
| 214 | 214 | } |
@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.05b'; |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @since 1.07.02 |
|
| 18 | - * |
|
| 19 | - * @param none |
|
| 20 | - * @return string The version of this plugin |
|
| 21 | - */ |
|
| 22 | - public static function plugin_version() { |
|
| 23 | - return self::$plug_version; |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * @since 1.07.02 |
|
| 18 | + * |
|
| 19 | + * @param none |
|
| 20 | + * @return string The version of this plugin |
|
| 21 | + */ |
|
| 22 | + public static function plugin_version() { |
|
| 23 | + return self::$plug_version; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function plugin_folder() { |
| 27 | 27 | return basename( self::plugin_path() ); |
@@ -31,29 +31,29 @@ discard block |
||
| 31 | 31 | return dirname( dirname( dirname( __FILE__ ) ) ); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public static function plugin_url() { |
|
| 35 | - //prevously FRM_URL constant |
|
| 34 | + public static function plugin_url() { |
|
| 35 | + //prevously FRM_URL constant |
|
| 36 | 36 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | public static function relative_plugin_url() { |
| 40 | 40 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return string Site URL |
|
| 45 | - */ |
|
| 46 | - public static function site_url() { |
|
| 47 | - return site_url(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Get the name of this site |
|
| 52 | - * Used for [sitename] shortcode |
|
| 53 | - * |
|
| 54 | - * @since 2.0 |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 43 | + /** |
|
| 44 | + * @return string Site URL |
|
| 45 | + */ |
|
| 46 | + public static function site_url() { |
|
| 47 | + return site_url(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Get the name of this site |
|
| 52 | + * Used for [sitename] shortcode |
|
| 53 | + * |
|
| 54 | + * @since 2.0 |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | 57 | public static function site_name() { |
| 58 | 58 | return get_option( 'blogname' ); |
| 59 | 59 | } |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | return add_query_arg( $query_args, $page ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Get the Formidable settings |
|
| 93 | - * |
|
| 94 | - * @since 2.0 |
|
| 95 | - * |
|
| 96 | - * @param None |
|
| 97 | - * @return FrmSettings $frm_setings |
|
| 98 | - */ |
|
| 91 | + /** |
|
| 92 | + * Get the Formidable settings |
|
| 93 | + * |
|
| 94 | + * @since 2.0 |
|
| 95 | + * |
|
| 96 | + * @param None |
|
| 97 | + * @return FrmSettings $frm_setings |
|
| 98 | + */ |
|
| 99 | 99 | public static function get_settings() { |
| 100 | 100 | global $frm_settings; |
| 101 | 101 | if ( empty( $frm_settings ) ) { |
@@ -156,50 +156,50 @@ discard block |
||
| 156 | 156 | return $is_formidable; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Check for certain page in Formidable settings |
|
| 161 | - * |
|
| 162 | - * @since 2.0 |
|
| 163 | - * |
|
| 164 | - * @param string $page The name of the page to check |
|
| 165 | - * @return boolean |
|
| 166 | - */ |
|
| 159 | + /** |
|
| 160 | + * Check for certain page in Formidable settings |
|
| 161 | + * |
|
| 162 | + * @since 2.0 |
|
| 163 | + * |
|
| 164 | + * @param string $page The name of the page to check |
|
| 165 | + * @return boolean |
|
| 166 | + */ |
|
| 167 | 167 | public static function is_admin_page( $page = 'formidable' ) { |
| 168 | - global $pagenow; |
|
| 168 | + global $pagenow; |
|
| 169 | 169 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 170 | - if ( $pagenow ) { |
|
| 170 | + if ( $pagenow ) { |
|
| 171 | 171 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 172 | 172 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 173 | - } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | return is_admin() && $get_page == $page; |
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Check for the form preview page |
|
| 180 | - * |
|
| 181 | - * @since 2.0 |
|
| 182 | - * |
|
| 183 | - * @param None |
|
| 184 | - * @return boolean |
|
| 185 | - */ |
|
| 186 | - public static function is_preview_page() { |
|
| 187 | - global $pagenow; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Check for the form preview page |
|
| 180 | + * |
|
| 181 | + * @since 2.0 |
|
| 182 | + * |
|
| 183 | + * @param None |
|
| 184 | + * @return boolean |
|
| 185 | + */ |
|
| 186 | + public static function is_preview_page() { |
|
| 187 | + global $pagenow; |
|
| 188 | 188 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 189 | 189 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Check for ajax except the form preview page |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * |
|
| 197 | - * @param None |
|
| 198 | - * @return boolean |
|
| 199 | - */ |
|
| 200 | - public static function doing_ajax() { |
|
| 201 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 202 | - } |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Check for ajax except the form preview page |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * |
|
| 197 | + * @param None |
|
| 198 | + * @return boolean |
|
| 199 | + */ |
|
| 200 | + public static function doing_ajax() { |
|
| 201 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | public static function js_suffix() { |
| 205 | 205 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -226,81 +226,81 @@ discard block |
||
| 226 | 226 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Check if on an admin page |
|
| 231 | - * |
|
| 232 | - * @since 2.0 |
|
| 233 | - * |
|
| 234 | - * @param None |
|
| 235 | - * @return boolean |
|
| 236 | - */ |
|
| 237 | - public static function is_admin() { |
|
| 238 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Check if value contains blank value or empty array |
|
| 243 | - * |
|
| 244 | - * @since 2.0 |
|
| 245 | - * @param mixed $value - value to check |
|
| 229 | + /** |
|
| 230 | + * Check if on an admin page |
|
| 231 | + * |
|
| 232 | + * @since 2.0 |
|
| 233 | + * |
|
| 234 | + * @param None |
|
| 235 | + * @return boolean |
|
| 236 | + */ |
|
| 237 | + public static function is_admin() { |
|
| 238 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Check if value contains blank value or empty array |
|
| 243 | + * |
|
| 244 | + * @since 2.0 |
|
| 245 | + * @param mixed $value - value to check |
|
| 246 | 246 | * @param string |
| 247 | - * @return boolean |
|
| 248 | - */ |
|
| 249 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 250 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 254 | - return ! self::is_empty_value( $value, $empty ); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Get any value from the $_SERVER |
|
| 259 | - * |
|
| 260 | - * @since 2.0 |
|
| 261 | - * @param string $value |
|
| 262 | - * @return string |
|
| 263 | - */ |
|
| 247 | + * @return boolean |
|
| 248 | + */ |
|
| 249 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 250 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 254 | + return ! self::is_empty_value( $value, $empty ); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * Get any value from the $_SERVER |
|
| 259 | + * |
|
| 260 | + * @since 2.0 |
|
| 261 | + * @param string $value |
|
| 262 | + * @return string |
|
| 263 | + */ |
|
| 264 | 264 | public static function get_server_value( $value ) { |
| 265 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * Check for the IP address in several places |
|
| 270 | - * Used by [ip] shortcode |
|
| 271 | - * |
|
| 272 | - * @return string The IP address of the current user |
|
| 273 | - */ |
|
| 274 | - public static function get_ip_address() { |
|
| 265 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * Check for the IP address in several places |
|
| 270 | + * Used by [ip] shortcode |
|
| 271 | + * |
|
| 272 | + * @return string The IP address of the current user |
|
| 273 | + */ |
|
| 274 | + public static function get_ip_address() { |
|
| 275 | 275 | $ip = ''; |
| 276 | 276 | foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { |
| 277 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 278 | - continue; |
|
| 279 | - } |
|
| 277 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 278 | + continue; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 281 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 282 | 282 | $ip = trim( $ip ); // just to be safe |
| 283 | 283 | |
| 284 | 284 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
| 285 | - return sanitize_text_field( $ip ); |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - } |
|
| 285 | + return sanitize_text_field( $ip ); |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | 290 | return sanitize_text_field( $ip ); |
| 291 | - } |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 293 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 294 | 294 | if ( strpos( $param, '[' ) ) { |
| 295 | 295 | $params = explode( '[', $param ); |
| 296 | - $param = $params[0]; |
|
| 297 | - } |
|
| 296 | + $param = $params[0]; |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | 299 | if ( $src == 'get' ) { |
| 300 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 301 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 302 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 303 | - } |
|
| 300 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 301 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 302 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 303 | + } |
|
| 304 | 304 | self::sanitize_value( $sanitize, $value ); |
| 305 | 305 | } else { |
| 306 | 306 | $value = self::get_simple_request( |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - return $value; |
|
| 328 | - } |
|
| 327 | + return $value; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | 330 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 331 | 331 | return self::get_simple_request( |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 397 | - * |
|
| 398 | - * @since 2.0.8 |
|
| 399 | - * @param string $value |
|
| 400 | - * @return string $value |
|
| 401 | - */ |
|
| 396 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 397 | + * |
|
| 398 | + * @since 2.0.8 |
|
| 399 | + * @param string $value |
|
| 400 | + * @return string $value |
|
| 401 | + */ |
|
| 402 | 402 | public static function preserve_backslashes( $value ) { |
| 403 | 403 | // If backslashes have already been added, don't add them again |
| 404 | 404 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -420,14 +420,14 @@ discard block |
||
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 424 | - $temp_values = $values; |
|
| 425 | - foreach ( $temp_values as $k => $val ) { |
|
| 426 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 423 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 424 | + $temp_values = $values; |
|
| 425 | + foreach ( $temp_values as $k => $val ) { |
|
| 426 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 427 | 427 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 428 | - } |
|
| 429 | - } |
|
| 430 | - } |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | 432 | /** |
| 433 | 433 | * Sanitize the value, and allow some HTML |
@@ -563,39 +563,39 @@ discard block |
||
| 563 | 563 | ); |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | - /** |
|
| 567 | - * Used when switching the action for a bulk action |
|
| 568 | - * @since 2.0 |
|
| 569 | - */ |
|
| 566 | + /** |
|
| 567 | + * Used when switching the action for a bulk action |
|
| 568 | + * @since 2.0 |
|
| 569 | + */ |
|
| 570 | 570 | public static function remove_get_action() { |
| 571 | 571 | if ( ! isset( $_GET ) ) { |
| 572 | 572 | return; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 576 | - if ( ! empty( $new_action ) ) { |
|
| 575 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 576 | + if ( ! empty( $new_action ) ) { |
|
| 577 | 577 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 578 | - } |
|
| 579 | - } |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | 580 | |
| 581 | - /** |
|
| 582 | - * Check the WP query for a parameter |
|
| 583 | - * |
|
| 584 | - * @since 2.0 |
|
| 585 | - * @return string|array |
|
| 586 | - */ |
|
| 587 | - public static function get_query_var( $value, $param ) { |
|
| 588 | - if ( $value != '' ) { |
|
| 589 | - return $value; |
|
| 590 | - } |
|
| 581 | + /** |
|
| 582 | + * Check the WP query for a parameter |
|
| 583 | + * |
|
| 584 | + * @since 2.0 |
|
| 585 | + * @return string|array |
|
| 586 | + */ |
|
| 587 | + public static function get_query_var( $value, $param ) { |
|
| 588 | + if ( $value != '' ) { |
|
| 589 | + return $value; |
|
| 590 | + } |
|
| 591 | 591 | |
| 592 | - global $wp_query; |
|
| 593 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 594 | - $value = $wp_query->query_vars[ $param ]; |
|
| 595 | - } |
|
| 592 | + global $wp_query; |
|
| 593 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 594 | + $value = $wp_query->query_vars[ $param ]; |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | - return $value; |
|
| 598 | - } |
|
| 597 | + return $value; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | /** |
| 601 | 601 | * @since 3.0 |
@@ -617,16 +617,16 @@ discard block |
||
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - /** |
|
| 621 | - * @param string $type |
|
| 622 | - */ |
|
| 623 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 624 | - // only load the form hooks once |
|
| 620 | + /** |
|
| 621 | + * @param string $type |
|
| 622 | + */ |
|
| 623 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 624 | + // only load the form hooks once |
|
| 625 | 625 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 626 | - if ( ! $hooks_loaded ) { |
|
| 626 | + if ( ! $hooks_loaded ) { |
|
| 627 | 627 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 628 | - } |
|
| 629 | - } |
|
| 628 | + } |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | 631 | /** |
| 632 | 632 | * Save all front-end js scripts into a single file |
@@ -651,18 +651,18 @@ discard block |
||
| 651 | 651 | $new_file->combine_files( $files ); |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - /** |
|
| 655 | - * Check a value from a shortcode to see if true or false. |
|
| 656 | - * True when value is 1, true, 'true', 'yes' |
|
| 657 | - * |
|
| 658 | - * @since 1.07.10 |
|
| 659 | - * |
|
| 660 | - * @param string $value The value to compare |
|
| 661 | - * @return boolean True or False |
|
| 662 | - */ |
|
| 654 | + /** |
|
| 655 | + * Check a value from a shortcode to see if true or false. |
|
| 656 | + * True when value is 1, true, 'true', 'yes' |
|
| 657 | + * |
|
| 658 | + * @since 1.07.10 |
|
| 659 | + * |
|
| 660 | + * @param string $value The value to compare |
|
| 661 | + * @return boolean True or False |
|
| 662 | + */ |
|
| 663 | 663 | public static function is_true( $value ) { |
| 664 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 665 | - } |
|
| 664 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 665 | + } |
|
| 666 | 666 | |
| 667 | 667 | public static function get_pages() { |
| 668 | 668 | $query = array( |
@@ -675,10 +675,10 @@ discard block |
||
| 675 | 675 | return get_posts( $query ); |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 679 | - $pages = self::get_pages(); |
|
| 678 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 679 | + $pages = self::get_pages(); |
|
| 680 | 680 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 681 | - ?> |
|
| 681 | + ?> |
|
| 682 | 682 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
| 683 | 683 | <option value=""> </option> |
| 684 | 684 | <?php foreach ( $pages as $page ) { ?> |
@@ -688,16 +688,16 @@ discard block |
||
| 688 | 688 | <?php } ?> |
| 689 | 689 | </select> |
| 690 | 690 | <?php |
| 691 | - } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | 693 | public static function post_edit_link( $post_id ) { |
| 694 | 694 | $post = get_post( $post_id ); |
| 695 | - if ( $post ) { |
|
| 695 | + if ( $post ) { |
|
| 696 | 696 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 697 | 697 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 698 | - } |
|
| 699 | - return ''; |
|
| 700 | - } |
|
| 698 | + } |
|
| 699 | + return ''; |
|
| 700 | + } |
|
| 701 | 701 | |
| 702 | 702 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 703 | 703 | ?> |
@@ -708,73 +708,73 @@ discard block |
||
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | public static function roles_options( $capability ) { |
| 711 | - global $frm_vars; |
|
| 711 | + global $frm_vars; |
|
| 712 | 712 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 713 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 714 | - } else { |
|
| 715 | - $editable_roles = get_editable_roles(); |
|
| 716 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 717 | - } |
|
| 713 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 714 | + } else { |
|
| 715 | + $editable_roles = get_editable_roles(); |
|
| 716 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 717 | + } |
|
| 718 | 718 | |
| 719 | - foreach ( $editable_roles as $role => $details ) { |
|
| 719 | + foreach ( $editable_roles as $role => $details ) { |
|
| 720 | 720 | $name = translate_user_role( $details['name'] ); |
| 721 | 721 | ?> |
| 722 | 722 | <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option> |
| 723 | 723 | <?php |
| 724 | 724 | unset( $role, $details ); |
| 725 | - } |
|
| 726 | - } |
|
| 725 | + } |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | 728 | public static function frm_capabilities( $type = 'auto' ) { |
| 729 | - $cap = array( |
|
| 730 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 731 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 732 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 733 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 734 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 735 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 736 | - ); |
|
| 729 | + $cap = array( |
|
| 730 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 731 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 732 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 733 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 734 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 735 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 736 | + ); |
|
| 737 | 737 | |
| 738 | 738 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 739 | - return $cap; |
|
| 740 | - } |
|
| 739 | + return $cap; |
|
| 740 | + } |
|
| 741 | 741 | |
| 742 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 743 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 744 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 745 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 742 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 743 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 744 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 745 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 746 | 746 | |
| 747 | - return $cap; |
|
| 748 | - } |
|
| 747 | + return $cap; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | 750 | public static function user_has_permission( $needed_role ) { |
| 751 | - if ( $needed_role == '-1' ) { |
|
| 752 | - return false; |
|
| 751 | + if ( $needed_role == '-1' ) { |
|
| 752 | + return false; |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 756 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 757 | - return true; |
|
| 758 | - } |
|
| 755 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 756 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 757 | + return true; |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 761 | - foreach ( $roles as $role ) { |
|
| 760 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 761 | + foreach ( $roles as $role ) { |
|
| 762 | 762 | if ( current_user_can( $role ) ) { |
| 763 | - return true; |
|
| 763 | + return true; |
|
| 764 | 764 | } |
| 765 | - if ( $role == $needed_role ) { |
|
| 766 | - break; |
|
| 765 | + if ( $role == $needed_role ) { |
|
| 766 | + break; |
|
| 767 | 767 | } |
| 768 | - } |
|
| 769 | - return false; |
|
| 770 | - } |
|
| 771 | - |
|
| 772 | - /** |
|
| 773 | - * Make sure administrators can see Formidable menu |
|
| 774 | - * |
|
| 775 | - * @since 2.0 |
|
| 776 | - */ |
|
| 777 | - public static function maybe_add_permissions() { |
|
| 768 | + } |
|
| 769 | + return false; |
|
| 770 | + } |
|
| 771 | + |
|
| 772 | + /** |
|
| 773 | + * Make sure administrators can see Formidable menu |
|
| 774 | + * |
|
| 775 | + * @since 2.0 |
|
| 776 | + */ |
|
| 777 | + public static function maybe_add_permissions() { |
|
| 778 | 778 | self::force_capability( 'frm_view_entries' ); |
| 779 | 779 | |
| 780 | 780 | if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
@@ -783,12 +783,12 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | $user_id = get_current_user_id(); |
| 785 | 785 | $user = new WP_User( $user_id ); |
| 786 | - $frm_roles = self::frm_capabilities(); |
|
| 787 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 786 | + $frm_roles = self::frm_capabilities(); |
|
| 787 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 788 | 788 | $user->add_cap( $frm_role ); |
| 789 | 789 | unset( $frm_role, $frm_role_description ); |
| 790 | - } |
|
| 791 | - } |
|
| 790 | + } |
|
| 791 | + } |
|
| 792 | 792 | |
| 793 | 793 | /** |
| 794 | 794 | * Make sure admins have permission to see the menu items |
@@ -804,28 +804,28 @@ discard block |
||
| 804 | 804 | } |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | - /** |
|
| 808 | - * Check if the user has permision for action. |
|
| 809 | - * Return permission message and stop the action if no permission |
|
| 810 | - * @since 2.0 |
|
| 811 | - * @param string $permission |
|
| 812 | - */ |
|
| 807 | + /** |
|
| 808 | + * Check if the user has permision for action. |
|
| 809 | + * Return permission message and stop the action if no permission |
|
| 810 | + * @since 2.0 |
|
| 811 | + * @param string $permission |
|
| 812 | + */ |
|
| 813 | 813 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 814 | 814 | $permission_error = self::permission_nonce_error( $permission ); |
| 815 | - if ( $permission_error !== false ) { |
|
| 816 | - if ( 'hide' == $show_message ) { |
|
| 817 | - $permission_error = ''; |
|
| 818 | - } |
|
| 815 | + if ( $permission_error !== false ) { |
|
| 816 | + if ( 'hide' == $show_message ) { |
|
| 817 | + $permission_error = ''; |
|
| 818 | + } |
|
| 819 | 819 | wp_die( esc_html( $permission_error ) ); |
| 820 | - } |
|
| 821 | - } |
|
| 822 | - |
|
| 823 | - /** |
|
| 824 | - * Check user permission and nonce |
|
| 825 | - * @since 2.0 |
|
| 826 | - * @param string $permission |
|
| 827 | - * @return false|string The permission message or false if allowed |
|
| 828 | - */ |
|
| 820 | + } |
|
| 821 | + } |
|
| 822 | + |
|
| 823 | + /** |
|
| 824 | + * Check user permission and nonce |
|
| 825 | + * @since 2.0 |
|
| 826 | + * @param string $permission |
|
| 827 | + * @return false|string The permission message or false if allowed |
|
| 828 | + */ |
|
| 829 | 829 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 830 | 830 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 831 | 831 | $frm_settings = self::get_settings(); |
@@ -834,22 +834,22 @@ discard block |
||
| 834 | 834 | |
| 835 | 835 | $error = false; |
| 836 | 836 | if ( empty( $nonce_name ) ) { |
| 837 | - return $error; |
|
| 838 | - } |
|
| 837 | + return $error; |
|
| 838 | + } |
|
| 839 | 839 | |
| 840 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 841 | - $frm_settings = self::get_settings(); |
|
| 842 | - $error = $frm_settings->admin_permission; |
|
| 843 | - } |
|
| 840 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 841 | + $frm_settings = self::get_settings(); |
|
| 842 | + $error = $frm_settings->admin_permission; |
|
| 843 | + } |
|
| 844 | 844 | |
| 845 | - return $error; |
|
| 846 | - } |
|
| 845 | + return $error; |
|
| 846 | + } |
|
| 847 | 847 | |
| 848 | - public static function checked( $values, $current ) { |
|
| 848 | + public static function checked( $values, $current ) { |
|
| 849 | 849 | if ( self::check_selected( $values, $current ) ) { |
| 850 | - echo ' checked="checked"'; |
|
| 850 | + echo ' checked="checked"'; |
|
| 851 | 851 | } |
| 852 | - } |
|
| 852 | + } |
|
| 853 | 853 | |
| 854 | 854 | public static function check_selected( $values, $current ) { |
| 855 | 855 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -887,24 +887,24 @@ discard block |
||
| 887 | 887 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - /** |
|
| 891 | - * Flatten a multi-dimensional array |
|
| 892 | - */ |
|
| 890 | + /** |
|
| 891 | + * Flatten a multi-dimensional array |
|
| 892 | + */ |
|
| 893 | 893 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 894 | - $return = array(); |
|
| 895 | - foreach ( $array as $key => $value ) { |
|
| 894 | + $return = array(); |
|
| 895 | + foreach ( $array as $key => $value ) { |
|
| 896 | 896 | if ( is_array( $value ) ) { |
| 897 | 897 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 898 | - } else { |
|
| 898 | + } else { |
|
| 899 | 899 | if ( $keys == 'keep' ) { |
| 900 | 900 | $return[ $key ] = $value; |
| 901 | 901 | } else { |
| 902 | 902 | $return[] = $value; |
| 903 | 903 | } |
| 904 | - } |
|
| 905 | - } |
|
| 906 | - return $return; |
|
| 907 | - } |
|
| 904 | + } |
|
| 905 | + } |
|
| 906 | + return $return; |
|
| 907 | + } |
|
| 908 | 908 | |
| 909 | 909 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 910 | 910 | $safe_text = str_replace( '"', '"', $text ); |
@@ -915,10 +915,10 @@ discard block |
||
| 915 | 915 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - /** |
|
| 919 | - * Add auto paragraphs to text areas |
|
| 920 | - * @since 2.0 |
|
| 921 | - */ |
|
| 918 | + /** |
|
| 919 | + * Add auto paragraphs to text areas |
|
| 920 | + * @since 2.0 |
|
| 921 | + */ |
|
| 922 | 922 | public static function use_wpautop( $content ) { |
| 923 | 923 | if ( apply_filters( 'frm_use_wpautop', true ) ) { |
| 924 | 924 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
@@ -927,26 +927,26 @@ discard block |
||
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | public static function replace_quotes( $val ) { |
| 930 | - //Replace double quotes |
|
| 930 | + //Replace double quotes |
|
| 931 | 931 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 932 | - //Replace single quotes |
|
| 933 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 934 | - return $val; |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - /** |
|
| 938 | - * @since 2.0 |
|
| 939 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 940 | - */ |
|
| 941 | - public static function jquery_ui_base_url() { |
|
| 932 | + //Replace single quotes |
|
| 933 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 934 | + return $val; |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + /** |
|
| 938 | + * @since 2.0 |
|
| 939 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 940 | + */ |
|
| 941 | + public static function jquery_ui_base_url() { |
|
| 942 | 942 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 943 | 943 | $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
| 944 | - return $url; |
|
| 945 | - } |
|
| 944 | + return $url; |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | - /** |
|
| 948 | - * @param string $handle |
|
| 949 | - */ |
|
| 947 | + /** |
|
| 948 | + * @param string $handle |
|
| 949 | + */ |
|
| 950 | 950 | public static function script_version( $handle, $default = 0 ) { |
| 951 | 951 | global $wp_scripts; |
| 952 | 952 | if ( ! $wp_scripts ) { |
@@ -968,12 +968,12 @@ discard block |
||
| 968 | 968 | |
| 969 | 969 | public static function js_redirect( $url ) { |
| 970 | 970 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 971 | - } |
|
| 971 | + } |
|
| 972 | 972 | |
| 973 | 973 | public static function get_user_id_param( $user_id ) { |
| 974 | 974 | if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
| 975 | - return $user_id; |
|
| 976 | - } |
|
| 975 | + return $user_id; |
|
| 976 | + } |
|
| 977 | 977 | |
| 978 | 978 | $user_id = sanitize_text_field( $user_id ); |
| 979 | 979 | if ( $user_id == 'current' ) { |
@@ -985,14 +985,14 @@ discard block |
||
| 985 | 985 | $user = get_user_by( 'login', $user_id ); |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - if ( $user ) { |
|
| 989 | - $user_id = $user->ID; |
|
| 990 | - } |
|
| 988 | + if ( $user ) { |
|
| 989 | + $user_id = $user->ID; |
|
| 990 | + } |
|
| 991 | 991 | unset( $user ); |
| 992 | - } |
|
| 992 | + } |
|
| 993 | 993 | |
| 994 | - return $user_id; |
|
| 995 | - } |
|
| 994 | + return $user_id; |
|
| 995 | + } |
|
| 996 | 996 | |
| 997 | 997 | public static function get_file_contents( $filename, $atts = array() ) { |
| 998 | 998 | if ( ! is_file( $filename ) ) { |
@@ -1007,28 +1007,28 @@ discard block |
||
| 1007 | 1007 | return $contents; |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | - /** |
|
| 1011 | - * @param string $table_name |
|
| 1012 | - * @param string $column |
|
| 1010 | + /** |
|
| 1011 | + * @param string $table_name |
|
| 1012 | + * @param string $column |
|
| 1013 | 1013 | * @param int $id |
| 1014 | 1014 | * @param int $num_chars |
| 1015 | - */ |
|
| 1016 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1017 | - $key = ''; |
|
| 1015 | + */ |
|
| 1016 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1017 | + $key = ''; |
|
| 1018 | 1018 | |
| 1019 | - if ( ! empty( $name ) ) { |
|
| 1019 | + if ( ! empty( $name ) ) { |
|
| 1020 | 1020 | $key = sanitize_key( $name ); |
| 1021 | - } |
|
| 1021 | + } |
|
| 1022 | 1022 | |
| 1023 | 1023 | if ( empty( $key ) ) { |
| 1024 | 1024 | $max_slug_value = pow( 36, $num_chars ); |
| 1025 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1025 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1026 | 1026 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 1027 | - } |
|
| 1027 | + } |
|
| 1028 | 1028 | |
| 1029 | 1029 | if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 1030 | 1030 | $key = $key . 'a'; |
| 1031 | - } |
|
| 1031 | + } |
|
| 1032 | 1032 | |
| 1033 | 1033 | $key_check = FrmDb::get_var( |
| 1034 | 1034 | $table_name, |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | ); |
| 1041 | 1041 | |
| 1042 | 1042 | if ( $key_check || is_numeric( $key_check ) ) { |
| 1043 | - $suffix = 2; |
|
| 1043 | + $suffix = 2; |
|
| 1044 | 1044 | do { |
| 1045 | 1045 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1046 | 1046 | $key_check = FrmDb::get_var( |
@@ -1054,19 +1054,19 @@ discard block |
||
| 1054 | 1054 | $suffix++; |
| 1055 | 1055 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1056 | 1056 | $key = $alt_post_name; |
| 1057 | - } |
|
| 1058 | - return $key; |
|
| 1059 | - } |
|
| 1060 | - |
|
| 1061 | - /** |
|
| 1062 | - * Editing a Form or Entry |
|
| 1063 | - * @param string $table |
|
| 1064 | - * @return bool|array |
|
| 1065 | - */ |
|
| 1066 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1067 | - if ( ! $record ) { |
|
| 1068 | - return false; |
|
| 1069 | - } |
|
| 1057 | + } |
|
| 1058 | + return $key; |
|
| 1059 | + } |
|
| 1060 | + |
|
| 1061 | + /** |
|
| 1062 | + * Editing a Form or Entry |
|
| 1063 | + * @param string $table |
|
| 1064 | + * @return bool|array |
|
| 1065 | + */ |
|
| 1066 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1067 | + if ( ! $record ) { |
|
| 1068 | + return false; |
|
| 1069 | + } |
|
| 1070 | 1070 | |
| 1071 | 1071 | if ( empty( $post_values ) ) { |
| 1072 | 1072 | $post_values = stripslashes_deep( $_POST ); |
@@ -1089,14 +1089,14 @@ discard block |
||
| 1089 | 1089 | |
| 1090 | 1090 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1091 | 1091 | |
| 1092 | - if ( $table == 'entries' ) { |
|
| 1093 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1094 | - } else if ( $table == 'forms' ) { |
|
| 1095 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1096 | - } |
|
| 1092 | + if ( $table == 'entries' ) { |
|
| 1093 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1094 | + } else if ( $table == 'forms' ) { |
|
| 1095 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1096 | + } |
|
| 1097 | 1097 | |
| 1098 | - return $values; |
|
| 1099 | - } |
|
| 1098 | + return $values; |
|
| 1099 | + } |
|
| 1100 | 1100 | |
| 1101 | 1101 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1102 | 1102 | if ( ! empty( $fields ) ) { |
@@ -1109,15 +1109,15 @@ discard block |
||
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1112 | - $post_values = $args['post_values']; |
|
| 1112 | + $post_values = $args['post_values']; |
|
| 1113 | 1113 | |
| 1114 | - if ( $args['default'] ) { |
|
| 1115 | - $meta_value = $field->default_value; |
|
| 1116 | - } else { |
|
| 1114 | + if ( $args['default'] ) { |
|
| 1115 | + $meta_value = $field->default_value; |
|
| 1116 | + } else { |
|
| 1117 | 1117 | if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 1118 | 1118 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 1119 | - $field->field_options['custom_field'] = ''; |
|
| 1120 | - } |
|
| 1119 | + $field->field_options['custom_field'] = ''; |
|
| 1120 | + } |
|
| 1121 | 1121 | $meta_value = FrmProEntryMetaHelper::get_post_value( |
| 1122 | 1122 | $record->post_id, |
| 1123 | 1123 | $field->field_options['post_field'], |
@@ -1129,31 +1129,31 @@ discard block |
||
| 1129 | 1129 | 'field' => $field, |
| 1130 | 1130 | ) |
| 1131 | 1131 | ); |
| 1132 | - } else { |
|
| 1132 | + } else { |
|
| 1133 | 1133 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1134 | - } |
|
| 1135 | - } |
|
| 1134 | + } |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | 1137 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1138 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1138 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1139 | 1139 | |
| 1140 | 1140 | $field_array = self::start_field_array( $field ); |
| 1141 | 1141 | $field_array['value'] = $new_value; |
| 1142 | 1142 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1143 | 1143 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1144 | 1144 | |
| 1145 | - $args['field_type'] = $field_type; |
|
| 1145 | + $args['field_type'] = $field_type; |
|
| 1146 | 1146 | |
| 1147 | 1147 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1148 | 1148 | |
| 1149 | 1149 | if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
| 1150 | - $field_array['unique_msg'] = ''; |
|
| 1151 | - } |
|
| 1150 | + $field_array['unique_msg'] = ''; |
|
| 1151 | + } |
|
| 1152 | 1152 | |
| 1153 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1153 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1154 | 1154 | |
| 1155 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1156 | - } |
|
| 1155 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1156 | + } |
|
| 1157 | 1157 | |
| 1158 | 1158 | /** |
| 1159 | 1159 | * @since 3.0 |
@@ -1174,20 +1174,20 @@ discard block |
||
| 1174 | 1174 | ); |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | - /** |
|
| 1178 | - * @param string $table |
|
| 1179 | - */ |
|
| 1177 | + /** |
|
| 1178 | + * @param string $table |
|
| 1179 | + */ |
|
| 1180 | 1180 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1181 | - if ( $table == 'entries' ) { |
|
| 1182 | - $form = $record->form_id; |
|
| 1181 | + if ( $table == 'entries' ) { |
|
| 1182 | + $form = $record->form_id; |
|
| 1183 | 1183 | FrmForm::maybe_get_form( $form ); |
| 1184 | - } else { |
|
| 1185 | - $form = $record; |
|
| 1186 | - } |
|
| 1184 | + } else { |
|
| 1185 | + $form = $record; |
|
| 1186 | + } |
|
| 1187 | 1187 | |
| 1188 | - if ( ! $form ) { |
|
| 1189 | - return; |
|
| 1190 | - } |
|
| 1188 | + if ( ! $form ) { |
|
| 1189 | + return; |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | 1192 | $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
| 1193 | 1193 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
@@ -1196,26 +1196,26 @@ discard block |
||
| 1196 | 1196 | return; |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | - foreach ( $form->options as $opt => $value ) { |
|
| 1200 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1201 | - } |
|
| 1199 | + foreach ( $form->options as $opt => $value ) { |
|
| 1200 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1201 | + } |
|
| 1202 | 1202 | |
| 1203 | 1203 | self::fill_form_defaults( $post_values, $values ); |
| 1204 | - } |
|
| 1204 | + } |
|
| 1205 | 1205 | |
| 1206 | - /** |
|
| 1207 | - * Set to POST value or default |
|
| 1208 | - */ |
|
| 1206 | + /** |
|
| 1207 | + * Set to POST value or default |
|
| 1208 | + */ |
|
| 1209 | 1209 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1210 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1210 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1211 | 1211 | |
| 1212 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1213 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1212 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1213 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1214 | 1214 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1215 | - } |
|
| 1215 | + } |
|
| 1216 | 1216 | |
| 1217 | 1217 | unset( $opt, $default ); |
| 1218 | - } |
|
| 1218 | + } |
|
| 1219 | 1219 | |
| 1220 | 1220 | if ( ! isset( $values['custom_style'] ) ) { |
| 1221 | 1221 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1224,10 +1224,10 @@ discard block |
||
| 1224 | 1224 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1225 | 1225 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1226 | 1226 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1227 | - } |
|
| 1227 | + } |
|
| 1228 | 1228 | unset( $h ); |
| 1229 | - } |
|
| 1230 | - } |
|
| 1229 | + } |
|
| 1230 | + } |
|
| 1231 | 1231 | |
| 1232 | 1232 | /** |
| 1233 | 1233 | * @since 2.2.10 |
@@ -1250,33 +1250,33 @@ discard block |
||
| 1250 | 1250 | if ( $possible_email_field ) { |
| 1251 | 1251 | $class .= 'show_frm_not_email_to'; |
| 1252 | 1252 | } |
| 1253 | - ?> |
|
| 1253 | + ?> |
|
| 1254 | 1254 | <li> |
| 1255 | 1255 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" >[<?php echo esc_attr( $args['id'] ); ?>]</a> |
| 1256 | 1256 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['key'] ); ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ); ?>]</a> |
| 1257 | 1257 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ); ?></a> |
| 1258 | 1258 | </li> |
| 1259 | 1259 | <?php |
| 1260 | - } |
|
| 1260 | + } |
|
| 1261 | 1261 | |
| 1262 | 1262 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1263 | - if ( is_array( $str ) ) { |
|
| 1264 | - return ''; |
|
| 1263 | + if ( is_array( $str ) ) { |
|
| 1264 | + return ''; |
|
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | - $length = (int) $length; |
|
| 1267 | + $length = (int) $length; |
|
| 1268 | 1268 | $str = wp_strip_all_tags( $str ); |
| 1269 | 1269 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1270 | 1270 | |
| 1271 | 1271 | if ( $length == 0 ) { |
| 1272 | - return ''; |
|
| 1273 | - } else if ( $length <= 10 ) { |
|
| 1272 | + return ''; |
|
| 1273 | + } else if ( $length <= 10 ) { |
|
| 1274 | 1274 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1275 | 1275 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1276 | - } |
|
| 1276 | + } |
|
| 1277 | 1277 | |
| 1278 | - $sub = ''; |
|
| 1279 | - $len = 0; |
|
| 1278 | + $sub = ''; |
|
| 1279 | + $len = 0; |
|
| 1280 | 1280 | |
| 1281 | 1281 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1282 | 1282 | |
@@ -1284,21 +1284,21 @@ discard block |
||
| 1284 | 1284 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1285 | 1285 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1286 | 1286 | if ( $total_len > $length && str_word_count( $sub ) ) { |
| 1287 | - break; |
|
| 1288 | - } |
|
| 1287 | + break; |
|
| 1288 | + } |
|
| 1289 | 1289 | |
| 1290 | - $sub .= $part; |
|
| 1290 | + $sub .= $part; |
|
| 1291 | 1291 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1292 | 1292 | |
| 1293 | 1293 | if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
| 1294 | - break; |
|
| 1295 | - } |
|
| 1294 | + break; |
|
| 1295 | + } |
|
| 1296 | 1296 | |
| 1297 | 1297 | unset( $total_len, $word ); |
| 1298 | - } |
|
| 1298 | + } |
|
| 1299 | 1299 | |
| 1300 | 1300 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1301 | - } |
|
| 1301 | + } |
|
| 1302 | 1302 | |
| 1303 | 1303 | public static function mb_function( $function_names, $args ) { |
| 1304 | 1304 | $mb_function_name = $function_names[0]; |
@@ -1311,17 +1311,17 @@ discard block |
||
| 1311 | 1311 | |
| 1312 | 1312 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1313 | 1313 | if ( empty( $date ) ) { |
| 1314 | - return $date; |
|
| 1315 | - } |
|
| 1314 | + return $date; |
|
| 1315 | + } |
|
| 1316 | 1316 | |
| 1317 | 1317 | if ( empty( $date_format ) ) { |
| 1318 | 1318 | $date_format = get_option( 'date_format' ); |
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
| 1322 | - $frmpro_settings = new FrmProSettings(); |
|
| 1322 | + $frmpro_settings = new FrmProSettings(); |
|
| 1323 | 1323 | $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
| 1324 | - } |
|
| 1324 | + } |
|
| 1325 | 1325 | |
| 1326 | 1326 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1327 | 1327 | |
@@ -1330,8 +1330,8 @@ discard block |
||
| 1330 | 1330 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | - return $formatted; |
|
| 1334 | - } |
|
| 1333 | + return $formatted; |
|
| 1334 | + } |
|
| 1335 | 1335 | |
| 1336 | 1336 | private static function add_time_to_date( $time_format, $date ) { |
| 1337 | 1337 | if ( empty( $time_format ) ) { |
@@ -1413,32 +1413,32 @@ discard block |
||
| 1413 | 1413 | ); |
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | - // Pagination Methods |
|
| 1416 | + // Pagination Methods |
|
| 1417 | 1417 | |
| 1418 | - /** |
|
| 1419 | - * @param integer $current_p |
|
| 1420 | - */ |
|
| 1418 | + /** |
|
| 1419 | + * @param integer $current_p |
|
| 1420 | + */ |
|
| 1421 | 1421 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1422 | 1422 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | - /** |
|
| 1426 | - * @param integer $current_p |
|
| 1427 | - */ |
|
| 1428 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1429 | - if ( $current_p == 1 ) { |
|
| 1430 | - return 1; |
|
| 1431 | - } else { |
|
| 1432 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1433 | - } |
|
| 1434 | - } |
|
| 1425 | + /** |
|
| 1426 | + * @param integer $current_p |
|
| 1427 | + */ |
|
| 1428 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1429 | + if ( $current_p == 1 ) { |
|
| 1430 | + return 1; |
|
| 1431 | + } else { |
|
| 1432 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1433 | + } |
|
| 1434 | + } |
|
| 1435 | 1435 | |
| 1436 | 1436 | /** |
| 1437 | 1437 | * @return array |
| 1438 | 1438 | */ |
| 1439 | 1439 | public static function json_to_array( $json_vars ) { |
| 1440 | - $vars = array(); |
|
| 1441 | - foreach ( $json_vars as $jv ) { |
|
| 1440 | + $vars = array(); |
|
| 1441 | + foreach ( $json_vars as $jv ) { |
|
| 1442 | 1442 | $jv_name = explode( '[', $jv['name'] ); |
| 1443 | 1443 | $last = count( $jv_name ) - 1; |
| 1444 | 1444 | foreach ( $jv_name as $p => $n ) { |
@@ -1455,77 +1455,77 @@ discard block |
||
| 1455 | 1455 | $l3 = $name; |
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1458 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1459 | 1459 | |
| 1460 | - switch ( $p ) { |
|
| 1461 | - case 0: |
|
| 1462 | - $l1 = $name; |
|
| 1463 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1460 | + switch ( $p ) { |
|
| 1461 | + case 0: |
|
| 1462 | + $l1 = $name; |
|
| 1463 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1464 | 1464 | break; |
| 1465 | 1465 | |
| 1466 | - case 1: |
|
| 1467 | - $l2 = $name; |
|
| 1468 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1466 | + case 1: |
|
| 1467 | + $l2 = $name; |
|
| 1468 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1469 | 1469 | break; |
| 1470 | 1470 | |
| 1471 | - case 2: |
|
| 1472 | - $l3 = $name; |
|
| 1473 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1471 | + case 2: |
|
| 1472 | + $l3 = $name; |
|
| 1473 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1474 | 1474 | break; |
| 1475 | 1475 | |
| 1476 | - case 3: |
|
| 1477 | - $l4 = $name; |
|
| 1478 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1479 | - } |
|
| 1476 | + case 3: |
|
| 1477 | + $l4 = $name; |
|
| 1478 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1479 | + } |
|
| 1480 | 1480 | |
| 1481 | 1481 | unset( $this_val, $n ); |
| 1482 | - } |
|
| 1482 | + } |
|
| 1483 | 1483 | |
| 1484 | 1484 | unset( $last, $jv ); |
| 1485 | - } |
|
| 1486 | - |
|
| 1487 | - return $vars; |
|
| 1488 | - } |
|
| 1489 | - |
|
| 1490 | - /** |
|
| 1491 | - * @param string $name |
|
| 1492 | - * @param string $l1 |
|
| 1493 | - */ |
|
| 1494 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1495 | - if ( $name == '' ) { |
|
| 1496 | - $vars[] = $val; |
|
| 1497 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1498 | - $vars[ $l1 ] = $val; |
|
| 1499 | - } |
|
| 1500 | - } |
|
| 1485 | + } |
|
| 1486 | + |
|
| 1487 | + return $vars; |
|
| 1488 | + } |
|
| 1489 | + |
|
| 1490 | + /** |
|
| 1491 | + * @param string $name |
|
| 1492 | + * @param string $l1 |
|
| 1493 | + */ |
|
| 1494 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1495 | + if ( $name == '' ) { |
|
| 1496 | + $vars[] = $val; |
|
| 1497 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1498 | + $vars[ $l1 ] = $val; |
|
| 1499 | + } |
|
| 1500 | + } |
|
| 1501 | 1501 | |
| 1502 | 1502 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1503 | - $tooltips = array( |
|
| 1504 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1505 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1506 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1507 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1508 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1509 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1510 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1511 | - ); |
|
| 1512 | - |
|
| 1513 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1514 | - return; |
|
| 1515 | - } |
|
| 1516 | - |
|
| 1517 | - if ( 'open' == $class ) { |
|
| 1518 | - echo ' frm_help"'; |
|
| 1519 | - } else { |
|
| 1520 | - echo ' class="frm_help"'; |
|
| 1521 | - } |
|
| 1503 | + $tooltips = array( |
|
| 1504 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1505 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1506 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1507 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1508 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1509 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1510 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1511 | + ); |
|
| 1512 | + |
|
| 1513 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1514 | + return; |
|
| 1515 | + } |
|
| 1516 | + |
|
| 1517 | + if ( 'open' == $class ) { |
|
| 1518 | + echo ' frm_help"'; |
|
| 1519 | + } else { |
|
| 1520 | + echo ' class="frm_help"'; |
|
| 1521 | + } |
|
| 1522 | 1522 | |
| 1523 | 1523 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1524 | 1524 | |
| 1525 | - if ( 'open' != $class ) { |
|
| 1526 | - echo '"'; |
|
| 1527 | - } |
|
| 1528 | - } |
|
| 1525 | + if ( 'open' != $class ) { |
|
| 1526 | + echo '"'; |
|
| 1527 | + } |
|
| 1528 | + } |
|
| 1529 | 1529 | |
| 1530 | 1530 | /** |
| 1531 | 1531 | * Add the current_page class to that page in the form nav |
@@ -1541,35 +1541,35 @@ discard block |
||
| 1541 | 1541 | } |
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | - /** |
|
| 1545 | - * Prepare and json_encode post content |
|
| 1546 | - * |
|
| 1547 | - * @since 2.0 |
|
| 1548 | - * |
|
| 1549 | - * @param array $post_content |
|
| 1550 | - * @return string $post_content ( json encoded array ) |
|
| 1551 | - */ |
|
| 1552 | - public static function prepare_and_encode( $post_content ) { |
|
| 1553 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1544 | + /** |
|
| 1545 | + * Prepare and json_encode post content |
|
| 1546 | + * |
|
| 1547 | + * @since 2.0 |
|
| 1548 | + * |
|
| 1549 | + * @param array $post_content |
|
| 1550 | + * @return string $post_content ( json encoded array ) |
|
| 1551 | + */ |
|
| 1552 | + public static function prepare_and_encode( $post_content ) { |
|
| 1553 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1554 | 1554 | foreach ( $post_content as $key => $val ) { |
| 1555 | 1555 | // Replace problematic characters (like ") |
| 1556 | 1556 | $val = str_replace( '"', '"', $val ); |
| 1557 | 1557 | |
| 1558 | 1558 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1559 | - unset( $key, $val ); |
|
| 1560 | - } |
|
| 1559 | + unset( $key, $val ); |
|
| 1560 | + } |
|
| 1561 | 1561 | |
| 1562 | - // json_encode the array |
|
| 1563 | - $post_content = json_encode( $post_content ); |
|
| 1562 | + // json_encode the array |
|
| 1563 | + $post_content = json_encode( $post_content ); |
|
| 1564 | 1564 | |
| 1565 | - // add extra slashes for \r\n since WP strips them |
|
| 1565 | + // add extra slashes for \r\n since WP strips them |
|
| 1566 | 1566 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1567 | 1567 | |
| 1568 | - // allow for " |
|
| 1569 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1568 | + // allow for " |
|
| 1569 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1570 | 1570 | |
| 1571 | - return $post_content; |
|
| 1572 | - } |
|
| 1571 | + return $post_content; |
|
| 1572 | + } |
|
| 1573 | 1573 | |
| 1574 | 1574 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1575 | 1575 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1592,54 +1592,54 @@ discard block |
||
| 1592 | 1592 | |
| 1593 | 1593 | public static function maybe_json_decode( $string ) { |
| 1594 | 1594 | if ( is_array( $string ) ) { |
| 1595 | - return $string; |
|
| 1596 | - } |
|
| 1595 | + return $string; |
|
| 1596 | + } |
|
| 1597 | 1597 | |
| 1598 | 1598 | $new_string = json_decode( $string, true ); |
| 1599 | 1599 | if ( function_exists( 'json_last_error' ) ) { |
| 1600 | 1600 | // php 5.3+ |
| 1601 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1602 | - $string = $new_string; |
|
| 1603 | - } |
|
| 1601 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1602 | + $string = $new_string; |
|
| 1603 | + } |
|
| 1604 | 1604 | } elseif ( isset( $new_string ) ) { |
| 1605 | 1605 | // php < 5.3 fallback |
| 1606 | - $string = $new_string; |
|
| 1607 | - } |
|
| 1608 | - return $string; |
|
| 1609 | - } |
|
| 1610 | - |
|
| 1611 | - /** |
|
| 1612 | - * @since 1.07.10 |
|
| 1613 | - * |
|
| 1614 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1615 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1616 | - */ |
|
| 1606 | + $string = $new_string; |
|
| 1607 | + } |
|
| 1608 | + return $string; |
|
| 1609 | + } |
|
| 1610 | + |
|
| 1611 | + /** |
|
| 1612 | + * @since 1.07.10 |
|
| 1613 | + * |
|
| 1614 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1615 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1616 | + */ |
|
| 1617 | 1617 | public static function maybe_highlight_menu( $post_type ) { |
| 1618 | - global $post; |
|
| 1618 | + global $post; |
|
| 1619 | 1619 | |
| 1620 | 1620 | if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
| 1621 | - return; |
|
| 1622 | - } |
|
| 1621 | + return; |
|
| 1622 | + } |
|
| 1623 | 1623 | |
| 1624 | 1624 | if ( is_object( $post ) && $post->post_type != $post_type ) { |
| 1625 | - return; |
|
| 1626 | - } |
|
| 1625 | + return; |
|
| 1626 | + } |
|
| 1627 | 1627 | |
| 1628 | - self::load_admin_wide_js(); |
|
| 1629 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1630 | - } |
|
| 1628 | + self::load_admin_wide_js(); |
|
| 1629 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1630 | + } |
|
| 1631 | 1631 | |
| 1632 | - /** |
|
| 1633 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1634 | - * @since 2.0 |
|
| 1635 | - */ |
|
| 1632 | + /** |
|
| 1633 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1634 | + * @since 2.0 |
|
| 1635 | + */ |
|
| 1636 | 1636 | public static function load_admin_wide_js( $load = true ) { |
| 1637 | - $version = FrmAppHelper::plugin_version(); |
|
| 1637 | + $version = FrmAppHelper::plugin_version(); |
|
| 1638 | 1638 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1639 | 1639 | |
| 1640 | 1640 | $global_strings = array( |
| 1641 | 1641 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1642 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1642 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1643 | 1643 | 'url' => FrmAppHelper::plugin_url(), |
| 1644 | 1644 | 'loading' => __( 'Loading…' ), |
| 1645 | 1645 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
@@ -1649,7 +1649,7 @@ discard block |
||
| 1649 | 1649 | if ( $load ) { |
| 1650 | 1650 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1651 | 1651 | } |
| 1652 | - } |
|
| 1652 | + } |
|
| 1653 | 1653 | |
| 1654 | 1654 | /** |
| 1655 | 1655 | * @since 2.0.9 |
@@ -1658,9 +1658,9 @@ discard block |
||
| 1658 | 1658 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | - /** |
|
| 1662 | - * @param string $location |
|
| 1663 | - */ |
|
| 1661 | + /** |
|
| 1662 | + * @param string $location |
|
| 1663 | + */ |
|
| 1664 | 1664 | public static function localize_script( $location ) { |
| 1665 | 1665 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1666 | 1666 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1726,27 +1726,27 @@ discard block |
||
| 1726 | 1726 | } |
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | - /** |
|
| 1729 | + /** |
|
| 1730 | 1730 | * echo the message on the plugins listing page |
| 1731 | - * @since 1.07.10 |
|
| 1732 | - * |
|
| 1733 | - * @param float $min_version The version the add-on requires |
|
| 1734 | - */ |
|
| 1731 | + * @since 1.07.10 |
|
| 1732 | + * |
|
| 1733 | + * @param float $min_version The version the add-on requires |
|
| 1734 | + */ |
|
| 1735 | 1735 | public static function min_version_notice( $min_version ) { |
| 1736 | - $frm_version = self::plugin_version(); |
|
| 1736 | + $frm_version = self::plugin_version(); |
|
| 1737 | 1737 | |
| 1738 | - // check if Formidable meets minimum requirements |
|
| 1738 | + // check if Formidable meets minimum requirements |
|
| 1739 | 1739 | if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
| 1740 | - return; |
|
| 1741 | - } |
|
| 1740 | + return; |
|
| 1741 | + } |
|
| 1742 | 1742 | |
| 1743 | 1743 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 1744 | 1744 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1745 | - esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1746 | - '</div></td></tr>'; |
|
| 1747 | - } |
|
| 1745 | + esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1746 | + '</div></td></tr>'; |
|
| 1747 | + } |
|
| 1748 | 1748 | |
| 1749 | - public static function locales( $type = 'date' ) { |
|
| 1749 | + public static function locales( $type = 'date' ) { |
|
| 1750 | 1750 | $locales = array( |
| 1751 | 1751 | 'en' => __( 'English', 'formidable' ), |
| 1752 | 1752 | '' => __( 'English/Western', 'formidable' ), |
@@ -1825,8 +1825,8 @@ discard block |
||
| 1825 | 1825 | $locales = array_diff_key( $locales, array_flip( $unset ) ); |
| 1826 | 1826 | $locales = apply_filters( 'frm_locales', $locales ); |
| 1827 | 1827 | |
| 1828 | - return $locales; |
|
| 1829 | - } |
|
| 1828 | + return $locales; |
|
| 1829 | + } |
|
| 1830 | 1830 | |
| 1831 | 1831 | /** |
| 1832 | 1832 | * Used to filter shortcode in text widgets |
@@ -874,6 +874,7 @@ discard block |
||
| 874 | 874 | * Get an array of the helper shortcodes to display in the customization panel |
| 875 | 875 | * |
| 876 | 876 | * @since 2.0.6 |
| 877 | + * @param boolean $settings_tab |
|
| 877 | 878 | */ |
| 878 | 879 | private static function get_shortcode_helpers( $settings_tab ) { |
| 879 | 880 | $entry_shortcodes = array( |
@@ -952,6 +953,9 @@ discard block |
||
| 952 | 953 | return $content; |
| 953 | 954 | } |
| 954 | 955 | |
| 956 | + /** |
|
| 957 | + * @param boolean $entry |
|
| 958 | + */ |
|
| 955 | 959 | private static function get_entry_by_param( &$entry ) { |
| 956 | 960 | if ( ! $entry || ! is_object( $entry ) ) { |
| 957 | 961 | if ( ! $entry || ! is_numeric( $entry ) ) { |
@@ -1235,6 +1239,9 @@ discard block |
||
| 1235 | 1239 | return $form; |
| 1236 | 1240 | } |
| 1237 | 1241 | |
| 1242 | + /** |
|
| 1243 | + * @param string $id |
|
| 1244 | + */ |
|
| 1238 | 1245 | private static function maybe_get_form_to_show( $id ) { |
| 1239 | 1246 | $form = false; |
| 1240 | 1247 | |
@@ -1648,6 +1655,7 @@ discard block |
||
| 1648 | 1655 | |
| 1649 | 1656 | /** |
| 1650 | 1657 | * @since 2.0.8 |
| 1658 | + * @param string $content |
|
| 1651 | 1659 | */ |
| 1652 | 1660 | private static function maybe_minimize_form( $atts, &$content ) { |
| 1653 | 1661 | // check if minimizing is turned on |
@@ -276,6 +276,9 @@ discard block |
||
| 276 | 276 | return $this->alter_builder_classes( $classes ); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | + /** |
|
| 280 | + * @param string $classes |
|
| 281 | + */ |
|
| 279 | 282 | protected function alter_builder_classes( $classes ) { |
| 280 | 283 | return $classes; |
| 281 | 284 | } |
@@ -470,6 +473,11 @@ discard block |
||
| 470 | 473 | return $html; |
| 471 | 474 | } |
| 472 | 475 | |
| 476 | + /** |
|
| 477 | + * @param string $html |
|
| 478 | + * |
|
| 479 | + * @return string |
|
| 480 | + */ |
|
| 473 | 481 | protected function after_replace_html_shortcodes( $args, $html ) { |
| 474 | 482 | return $html; |
| 475 | 483 | } |
@@ -765,6 +773,7 @@ discard block |
||
| 765 | 773 | * Link input to field description for screen readers |
| 766 | 774 | * |
| 767 | 775 | * @since 3.0 |
| 776 | + * @param string $input_html |
|
| 768 | 777 | */ |
| 769 | 778 | protected function add_aria_description( $args, &$input_html ) { |
| 770 | 779 | if ( $this->get_field_column( 'description' ) != '' ) { |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmFormActionsController { |
| 4 | - public static $action_post_type = 'frm_form_actions'; |
|
| 5 | - public static $registered_actions; |
|
| 4 | + public static $action_post_type = 'frm_form_actions'; |
|
| 5 | + public static $registered_actions; |
|
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * Variables saved in the post: |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * menu_order: form id |
| 11 | 11 | * post_excerpt: action type |
| 12 | 12 | */ |
| 13 | - public static function register_post_types() { |
|
| 13 | + public static function register_post_types() { |
|
| 14 | 14 | register_post_type( |
| 15 | 15 | self::$action_post_type, |
| 16 | 16 | array( |
@@ -27,84 +27,84 @@ discard block |
||
| 27 | 27 | ) |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - self::actions_init(); |
|
| 31 | - } |
|
| 30 | + self::actions_init(); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public static function actions_init() { |
|
| 34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | - self::register_actions(); |
|
| 36 | - do_action( 'frm_form_actions_init' ); |
|
| 37 | - } |
|
| 33 | + public static function actions_init() { |
|
| 34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | + self::register_actions(); |
|
| 36 | + do_action( 'frm_form_actions_init' ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public static function register_actions() { |
|
| 39 | + public static function register_actions() { |
|
| 40 | 40 | $action_classes = array( |
| 41 | - 'email' => 'FrmEmailAction', |
|
| 42 | - 'wppost' => 'FrmDefPostAction', |
|
| 43 | - 'register' => 'FrmDefRegAction', |
|
| 44 | - 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | - //'aweber' => 'FrmDefAweberAction', |
|
| 46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | - 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | - 'payment' => 'FrmDefHrsAction', |
|
| 49 | - ); |
|
| 41 | + 'email' => 'FrmEmailAction', |
|
| 42 | + 'wppost' => 'FrmDefPostAction', |
|
| 43 | + 'register' => 'FrmDefRegAction', |
|
| 44 | + 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | + //'aweber' => 'FrmDefAweberAction', |
|
| 46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | + 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | + 'payment' => 'FrmDefHrsAction', |
|
| 49 | + ); |
|
| 50 | 50 | $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes ); |
| 51 | 51 | |
| 52 | 52 | include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); |
| 53 | 53 | include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); |
| 54 | 54 | |
| 55 | - foreach ( $action_classes as $action_class ) { |
|
| 55 | + foreach ( $action_classes as $action_class ) { |
|
| 56 | 56 | self::$registered_actions->register( $action_class ); |
| 57 | - } |
|
| 58 | - } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | public static function get_form_actions( $action = 'all' ) { |
| 61 | - $temp_actions = self::$registered_actions; |
|
| 61 | + $temp_actions = self::$registered_actions; |
|
| 62 | 62 | if ( empty( $temp_actions ) ) { |
| 63 | - self::actions_init(); |
|
| 64 | - $temp_actions = self::$registered_actions->actions; |
|
| 65 | - } else { |
|
| 66 | - $temp_actions = $temp_actions->actions; |
|
| 67 | - } |
|
| 63 | + self::actions_init(); |
|
| 64 | + $temp_actions = self::$registered_actions->actions; |
|
| 65 | + } else { |
|
| 66 | + $temp_actions = $temp_actions->actions; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $actions = array(); |
|
| 69 | + $actions = array(); |
|
| 70 | 70 | |
| 71 | - foreach ( $temp_actions as $a ) { |
|
| 72 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
| 73 | - return $a; |
|
| 74 | - } |
|
| 71 | + foreach ( $temp_actions as $a ) { |
|
| 72 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
| 73 | + return $a; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | $actions[ $a->id_base ] = $a; |
| 77 | - } |
|
| 78 | - unset( $temp_actions, $a ); |
|
| 79 | - |
|
| 80 | - $action_limit = 10; |
|
| 81 | - if ( count( $actions ) <= $action_limit ) { |
|
| 82 | - return $actions; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - // remove the last few inactive icons if there are too many |
|
| 86 | - $temp_actions = $actions; |
|
| 87 | - arsort( $temp_actions ); |
|
| 88 | - foreach ( $temp_actions as $type => $a ) { |
|
| 89 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 77 | + } |
|
| 78 | + unset( $temp_actions, $a ); |
|
| 79 | + |
|
| 80 | + $action_limit = 10; |
|
| 81 | + if ( count( $actions ) <= $action_limit ) { |
|
| 82 | + return $actions; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + // remove the last few inactive icons if there are too many |
|
| 86 | + $temp_actions = $actions; |
|
| 87 | + arsort( $temp_actions ); |
|
| 88 | + foreach ( $temp_actions as $type => $a ) { |
|
| 89 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 90 | 90 | unset( $actions[ $type ] ); |
| 91 | - if ( count( $actions ) <= $action_limit ) { |
|
| 92 | - break; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - unset( $type, $a ); |
|
| 96 | - } |
|
| 91 | + if ( count( $actions ) <= $action_limit ) { |
|
| 92 | + break; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + unset( $type, $a ); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - return $actions; |
|
| 99 | - } |
|
| 98 | + return $actions; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * @since 2.0 |
| 103 | 103 | */ |
| 104 | - public static function list_actions( $form, $values ) { |
|
| 105 | - if ( empty( $form ) ) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 104 | + public static function list_actions( $form, $values ) { |
|
| 105 | + if ( empty( $form ) ) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Use this hook to migrate old settings into a new action |
@@ -118,72 +118,72 @@ discard block |
||
| 118 | 118 | ); |
| 119 | 119 | $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters ); |
| 120 | 120 | |
| 121 | - $action_controls = self::get_form_actions(); |
|
| 121 | + $action_controls = self::get_form_actions(); |
|
| 122 | 122 | |
| 123 | - $action_map = array(); |
|
| 123 | + $action_map = array(); |
|
| 124 | 124 | |
| 125 | 125 | foreach ( $action_controls as $key => $control ) { |
| 126 | - $action_map[ $control->id_base ] = $key; |
|
| 127 | - } |
|
| 126 | + $action_map[ $control->id_base ] = $key; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - foreach ( $form_actions as $action ) { |
|
| 130 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 131 | - // don't try and show settings if action no longer exists |
|
| 132 | - continue; |
|
| 133 | - } |
|
| 129 | + foreach ( $form_actions as $action ) { |
|
| 130 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 131 | + // don't try and show settings if action no longer exists |
|
| 132 | + continue; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 136 | - } |
|
| 137 | - } |
|
| 135 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 140 | 140 | $action_control->_set( $action_key ); |
| 141 | 141 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - public static function add_form_action() { |
|
| 144 | + public static function add_form_action() { |
|
| 145 | 145 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 146 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 146 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 147 | 147 | |
| 148 | - global $frm_vars; |
|
| 148 | + global $frm_vars; |
|
| 149 | 149 | |
| 150 | 150 | $action_key = absint( $_POST['list_id'] ); |
| 151 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 151 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 152 | 152 | |
| 153 | - $action_control = self::get_form_actions( $action_type ); |
|
| 153 | + $action_control = self::get_form_actions( $action_type ); |
|
| 154 | 154 | $action_control->_set( $action_key ); |
| 155 | 155 | |
| 156 | - $form_id = absint( $_POST['form_id'] ); |
|
| 156 | + $form_id = absint( $_POST['form_id'] ); |
|
| 157 | 157 | |
| 158 | 158 | $form_action = $action_control->prepare_new( $form_id ); |
| 159 | 159 | |
| 160 | - $values = array(); |
|
| 160 | + $values = array(); |
|
| 161 | 161 | $form = self::fields_to_values( $form_id, $values ); |
| 162 | 162 | |
| 163 | 163 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 164 | - wp_die(); |
|
| 165 | - } |
|
| 164 | + wp_die(); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - public static function fill_action() { |
|
| 167 | + public static function fill_action() { |
|
| 168 | 168 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 169 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 169 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 170 | 170 | |
| 171 | - $action_key = absint( $_POST['action_id'] ); |
|
| 172 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 171 | + $action_key = absint( $_POST['action_id'] ); |
|
| 172 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 173 | 173 | |
| 174 | - $action_control = self::get_form_actions( $action_type ); |
|
| 174 | + $action_control = self::get_form_actions( $action_type ); |
|
| 175 | 175 | if ( empty( $action_control ) ) { |
| 176 | - wp_die(); |
|
| 177 | - } |
|
| 176 | + wp_die(); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - $form_action = $action_control->get_single_action( $action_key ); |
|
| 179 | + $form_action = $action_control->get_single_action( $action_key ); |
|
| 180 | 180 | |
| 181 | - $values = array(); |
|
| 181 | + $values = array(); |
|
| 182 | 182 | $form = self::fields_to_values( $form_action->menu_order, $values ); |
| 183 | 183 | |
| 184 | 184 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
| 185 | - wp_die(); |
|
| 186 | - } |
|
| 185 | + wp_die(); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | private static function fields_to_values( $form_id, array &$values ) { |
| 189 | 189 | $form = FrmForm::getOne( $form_id ); |
@@ -194,19 +194,19 @@ discard block |
||
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | 196 | $fields = FrmField::get_all_for_form( $form->id ); |
| 197 | - foreach ( $fields as $k => $f ) { |
|
| 198 | - $f = (array) $f; |
|
| 199 | - $opts = (array) $f['field_options']; |
|
| 197 | + foreach ( $fields as $k => $f ) { |
|
| 198 | + $f = (array) $f; |
|
| 199 | + $opts = (array) $f['field_options']; |
|
| 200 | 200 | $f = array_merge( $opts, $f ); |
| 201 | - if ( ! isset( $f['post_field'] ) ) { |
|
| 202 | - $f['post_field'] = ''; |
|
| 203 | - } |
|
| 204 | - $values['fields'][] = $f; |
|
| 201 | + if ( ! isset( $f['post_field'] ) ) { |
|
| 202 | + $f['post_field'] = ''; |
|
| 203 | + } |
|
| 204 | + $values['fields'][] = $f; |
|
| 205 | 205 | unset( $k, $f ); |
| 206 | - } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - return $form; |
|
| 209 | - } |
|
| 208 | + return $form; |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | 211 | public static function update_settings( $form_id ) { |
| 212 | 212 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | wp_die( esc_html__( 'You do not have permission to do that', 'formidable' ) ); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - global $wpdb; |
|
| 217 | + global $wpdb; |
|
| 218 | 218 | |
| 219 | - $registered_actions = self::$registered_actions->actions; |
|
| 219 | + $registered_actions = self::$registered_actions->actions; |
|
| 220 | 220 | |
| 221 | 221 | $old_actions = FrmDb::get_col( |
| 222 | 222 | $wpdb->posts, |
@@ -226,23 +226,23 @@ discard block |
||
| 226 | 226 | ), |
| 227 | 227 | 'ID' |
| 228 | 228 | ); |
| 229 | - $new_actions = array(); |
|
| 229 | + $new_actions = array(); |
|
| 230 | 230 | |
| 231 | - foreach ( $registered_actions as $registered_action ) { |
|
| 231 | + foreach ( $registered_actions as $registered_action ) { |
|
| 232 | 232 | $action_ids = $registered_action->update_callback( $form_id ); |
| 233 | - if ( ! empty( $action_ids ) ) { |
|
| 234 | - $new_actions[] = $action_ids; |
|
| 235 | - } |
|
| 236 | - } |
|
| 233 | + if ( ! empty( $action_ids ) ) { |
|
| 234 | + $new_actions[] = $action_ids; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - //Only use array_merge if there are new actions |
|
| 239 | - if ( ! empty( $new_actions ) ) { |
|
| 240 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 241 | - } |
|
| 242 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 238 | + //Only use array_merge if there are new actions |
|
| 239 | + if ( ! empty( $new_actions ) ) { |
|
| 240 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 241 | + } |
|
| 242 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 243 | 243 | |
| 244 | 244 | self::delete_missing_actions( $old_actions ); |
| 245 | - } |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | public static function delete_missing_actions( $old_actions ) { |
| 248 | 248 | if ( ! empty( $old_actions ) ) { |
@@ -262,22 +262,22 @@ discard block |
||
| 262 | 262 | self::trigger_actions( $event, $form_id, $entry_id, 'all', $args ); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - /** |
|
| 266 | - * @param string $event |
|
| 267 | - */ |
|
| 265 | + /** |
|
| 266 | + * @param string $event |
|
| 267 | + */ |
|
| 268 | 268 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 269 | 269 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
| 270 | 270 | |
| 271 | 271 | if ( empty( $form_actions ) ) { |
| 272 | - return; |
|
| 273 | - } |
|
| 272 | + return; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | FrmForm::maybe_get_form( $form ); |
| 276 | 276 | |
| 277 | - $link_settings = self::get_form_actions( $type ); |
|
| 278 | - if ( 'all' != $type ) { |
|
| 279 | - $link_settings = array( $type => $link_settings ); |
|
| 280 | - } |
|
| 277 | + $link_settings = self::get_form_actions( $type ); |
|
| 278 | + if ( 'all' != $type ) { |
|
| 279 | + $link_settings = array( $type => $link_settings ); |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | 282 | $stored_actions = array(); |
| 283 | 283 | $action_priority = array(); |
@@ -288,17 +288,17 @@ discard block |
||
| 288 | 288 | $this_event = $event; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - foreach ( $form_actions as $action ) { |
|
| 291 | + foreach ( $form_actions as $action ) { |
|
| 292 | 292 | |
| 293 | 293 | $skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) ); |
| 294 | 294 | $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) ); |
| 295 | 295 | if ( $skip_this_action ) { |
| 296 | - continue; |
|
| 297 | - } |
|
| 296 | + continue; |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - if ( ! is_object( $entry ) ) { |
|
| 300 | - $entry = FrmEntry::getOne( $entry, true ); |
|
| 301 | - } |
|
| 299 | + if ( ! is_object( $entry ) ) { |
|
| 300 | + $entry = FrmEntry::getOne( $entry, true ); |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | 303 | if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) { |
| 304 | 304 | continue; |
@@ -312,64 +312,64 @@ discard block |
||
| 312 | 312 | if ( ! $trigger_children ) { |
| 313 | 313 | continue; |
| 314 | 314 | } |
| 315 | - } |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - // check conditional logic |
|
| 317 | + // check conditional logic |
|
| 318 | 318 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
| 319 | - if ( $stop ) { |
|
| 320 | - continue; |
|
| 321 | - } |
|
| 319 | + if ( $stop ) { |
|
| 320 | + continue; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - // store actions so they can be triggered with the correct priority |
|
| 324 | - $stored_actions[ $action->ID ] = $action; |
|
| 325 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 323 | + // store actions so they can be triggered with the correct priority |
|
| 324 | + $stored_actions[ $action->ID ] = $action; |
|
| 325 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 326 | 326 | |
| 327 | 327 | unset( $action ); |
| 328 | - } |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - if ( ! empty( $stored_actions ) ) { |
|
| 330 | + if ( ! empty( $stored_actions ) ) { |
|
| 331 | 331 | asort( $action_priority ); |
| 332 | 332 | |
| 333 | - // make sure hooks are loaded |
|
| 334 | - new FrmNotification(); |
|
| 333 | + // make sure hooks are loaded |
|
| 334 | + new FrmNotification(); |
|
| 335 | 335 | |
| 336 | - foreach ( $action_priority as $action_id => $priority ) { |
|
| 337 | - $action = $stored_actions[ $action_id ]; |
|
| 336 | + foreach ( $action_priority as $action_id => $priority ) { |
|
| 337 | + $action = $stored_actions[ $action_id ]; |
|
| 338 | 338 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
| 339 | 339 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
| 340 | 340 | |
| 341 | - // If post is created, get updated $entry object |
|
| 342 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 341 | + // If post is created, get updated $entry object |
|
| 342 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 343 | 343 | $entry = FrmEntry::getOne( $entry->id, true ); |
| 344 | - } |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - } |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | 348 | |
| 349 | 349 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 350 | 350 | if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { |
| 351 | - // continue if we know which actions to copy |
|
| 352 | - return; |
|
| 353 | - } |
|
| 351 | + // continue if we know which actions to copy |
|
| 352 | + return; |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | 355 | $action_controls = self::get_form_actions(); |
| 356 | 356 | |
| 357 | - foreach ( $action_controls as $action_control ) { |
|
| 358 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 359 | - unset( $action_control ); |
|
| 360 | - } |
|
| 361 | - } |
|
| 357 | + foreach ( $action_controls as $action_control ) { |
|
| 358 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 359 | + unset( $action_control ); |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - public static function limit_by_type( $where ) { |
|
| 364 | - global $frm_vars, $wpdb; |
|
| 363 | + public static function limit_by_type( $where ) { |
|
| 364 | + global $frm_vars, $wpdb; |
|
| 365 | 365 | |
| 366 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 367 | - return $where; |
|
| 368 | - } |
|
| 366 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 367 | + return $where; |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 371 | - return $where; |
|
| 372 | - } |
|
| 370 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 371 | + return $where; |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | foreach ( $keys as $key ) { |
| 397 | 397 | // don't register new action if old action with the same id is already registered |
| 398 | 398 | if ( ! isset( $this->actions[ $key ] ) ) { |
| 399 | - $this->actions[ $key ]->_register(); |
|
| 399 | + $this->actions[ $key ]->_register(); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | } |
@@ -149,41 +149,41 @@ discard block |
||
| 149 | 149 | return apply_filters( 'frm_pro_available_fields', $fields ); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - public static function create( $values, $return = true ) { |
|
| 153 | - global $wpdb, $frm_duplicate_ids; |
|
| 152 | + public static function create( $values, $return = true ) { |
|
| 153 | + global $wpdb, $frm_duplicate_ids; |
|
| 154 | 154 | |
| 155 | - $new_values = array(); |
|
| 155 | + $new_values = array(); |
|
| 156 | 156 | $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name']; |
| 157 | 157 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 158 | 158 | |
| 159 | 159 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 160 | 160 | $new_values[ $col ] = $values[ $col ]; |
| 161 | - } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - $new_values['options'] = $values['options']; |
|
| 163 | + $new_values['options'] = $values['options']; |
|
| 164 | 164 | |
| 165 | 165 | $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
| 166 | 166 | $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0; |
| 167 | 167 | $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
| 168 | - $new_values['field_options'] = $values['field_options']; |
|
| 168 | + $new_values['field_options'] = $values['field_options']; |
|
| 169 | 169 | $new_values['created_at'] = current_time( 'mysql', 1 ); |
| 170 | 170 | |
| 171 | 171 | if ( isset( $values['id'] ) ) { |
| 172 | 172 | $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
| 173 | 173 | $new_values = apply_filters( 'frm_duplicated_field', $new_values ); |
| 174 | - } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | self::preserve_format_option_backslashes( $new_values ); |
| 177 | 177 | |
| 178 | 178 | foreach ( $new_values as $k => $v ) { |
| 179 | - if ( is_array( $v ) ) { |
|
| 179 | + if ( is_array( $v ) ) { |
|
| 180 | 180 | $new_values[ $k ] = serialize( $v ); |
| 181 | 181 | } |
| 182 | - unset( $k, $v ); |
|
| 183 | - } |
|
| 182 | + unset( $k, $v ); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - //if(isset($values['id']) and is_numeric($values['id'])) |
|
| 186 | - // $new_values['id'] = $values['id']; |
|
| 185 | + //if(isset($values['id']) and is_numeric($values['id'])) |
|
| 186 | + // $new_values['id'] = $values['id']; |
|
| 187 | 187 | |
| 188 | 188 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
| 189 | 189 | $new_id = 0; |
@@ -204,10 +204,10 @@ discard block |
||
| 204 | 204 | } else { |
| 205 | 205 | return false; |
| 206 | 206 | } |
| 207 | - } |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
| 210 | - global $frm_duplicate_ids; |
|
| 209 | + public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
| 210 | + global $frm_duplicate_ids; |
|
| 211 | 211 | |
| 212 | 212 | $where = array( |
| 213 | 213 | array( |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | ); |
| 219 | 219 | $fields = self::getAll( $where, 'field_order', '', $blog_id ); |
| 220 | 220 | |
| 221 | - foreach ( (array) $fields as $field ) { |
|
| 221 | + foreach ( (array) $fields as $field ) { |
|
| 222 | 222 | $new_key = $copy_keys ? $field->field_key : ''; |
| 223 | 223 | if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) { |
| 224 | 224 | $new_key = rtrim( $new_key, 2 ); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $values = array(); |
|
| 228 | - FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
| 227 | + $values = array(); |
|
| 228 | + FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
| 229 | 229 | |
| 230 | 230 | // If this is a repeating section, create new form |
| 231 | 231 | if ( self::is_repeating_field( $field ) ) { |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | $frm_duplicate_ids[ $field->id ] = $new_id; |
| 257 | 257 | $frm_duplicate_ids[ $field->field_key ] = $new_id; |
| 258 | 258 | unset( $field ); |
| 259 | - } |
|
| 260 | - } |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | public static function update( $id, $values ) { |
| 263 | - global $wpdb; |
|
| 263 | + global $wpdb; |
|
| 264 | 264 | |
| 265 | 265 | $id = absint( $id ); |
| 266 | 266 | |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | if ( isset( $values['required'] ) ) { |
| 272 | - $values['required'] = (int) $values['required']; |
|
| 273 | - } |
|
| 272 | + $values['required'] = (int) $values['required']; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | self::preserve_format_option_backslashes( $values ); |
| 276 | 276 | |
@@ -292,41 +292,41 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) ); |
| 294 | 294 | |
| 295 | - $form_id = 0; |
|
| 295 | + $form_id = 0; |
|
| 296 | 296 | if ( isset( $values['form_id'] ) ) { |
| 297 | - $form_id = absint( $values['form_id'] ); |
|
| 297 | + $form_id = absint( $values['form_id'] ); |
|
| 298 | 298 | } else { |
| 299 | 299 | $field = self::getOne( $id ); |
| 300 | - if ( $field ) { |
|
| 301 | - $form_id = $field->form_id; |
|
| 302 | - } |
|
| 300 | + if ( $field ) { |
|
| 301 | + $form_id = $field->form_id; |
|
| 302 | + } |
|
| 303 | 303 | unset( $field ); |
| 304 | - } |
|
| 304 | + } |
|
| 305 | 305 | unset( $values ); |
| 306 | 306 | |
| 307 | 307 | if ( $query_results ) { |
| 308 | - wp_cache_delete( $id, 'frm_field' ); |
|
| 309 | - if ( $form_id ) { |
|
| 310 | - self::delete_form_transient( $form_id ); |
|
| 311 | - } |
|
| 312 | - } |
|
| 308 | + wp_cache_delete( $id, 'frm_field' ); |
|
| 309 | + if ( $form_id ) { |
|
| 310 | + self::delete_form_transient( $form_id ); |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - return $query_results; |
|
| 315 | - } |
|
| 314 | + return $query_results; |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | - * Keep backslashes in the phone format option |
|
| 319 | - * |
|
| 320 | - * @since 2.0.8 |
|
| 321 | - * @param $values array - pass by reference |
|
| 322 | - */ |
|
| 318 | + * Keep backslashes in the phone format option |
|
| 319 | + * |
|
| 320 | + * @since 2.0.8 |
|
| 321 | + * @param $values array - pass by reference |
|
| 322 | + */ |
|
| 323 | 323 | private static function preserve_format_option_backslashes( &$values ) { |
| 324 | 324 | if ( isset( $values['field_options']['format'] ) ) { |
| 325 | 325 | $values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] ); |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - public static function destroy( $id ) { |
|
| 329 | + public static function destroy( $id ) { |
|
| 330 | 330 | global $wpdb; |
| 331 | 331 | |
| 332 | 332 | do_action( 'frm_before_destroy_field', $id ); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) ); |
| 343 | 343 | return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) ); |
| 344 | - } |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | public static function delete_form_transient( $form_id ) { |
| 347 | 347 | $form_id = absint( $form_id ); |
@@ -356,10 +356,10 @@ discard block |
||
| 356 | 356 | FrmDb::cache_delete_group( 'frm_field' ); |
| 357 | 357 | |
| 358 | 358 | $form = FrmForm::getOne( $form_id ); |
| 359 | - if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) { |
|
| 360 | - self::delete_form_transient( $form->parent_form_id ); |
|
| 361 | - } |
|
| 362 | - } |
|
| 359 | + if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) { |
|
| 360 | + self::delete_form_transient( $form->parent_form_id ); |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | 364 | /** |
| 365 | 365 | * If $field is numeric, get the field object |
@@ -375,27 +375,27 @@ discard block |
||
| 375 | 375 | return null; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - global $wpdb; |
|
| 378 | + global $wpdb; |
|
| 379 | 379 | |
| 380 | 380 | $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s'; |
| 381 | 381 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // WPCS: unprepared SQL ok. |
| 382 | 382 | |
| 383 | - $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
| 383 | + $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
| 384 | 384 | |
| 385 | 385 | if ( empty( $results ) ) { |
| 386 | - return $results; |
|
| 387 | - } |
|
| 386 | + return $results; |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | 389 | if ( is_numeric( $id ) ) { |
| 390 | 390 | FrmDb::set_cache( $results->field_key, $results, 'frm_field' ); |
| 391 | - } else if ( $results ) { |
|
| 391 | + } else if ( $results ) { |
|
| 392 | 392 | FrmDb::set_cache( $results->id, $results, 'frm_field' ); |
| 393 | - } |
|
| 393 | + } |
|
| 394 | 394 | |
| 395 | 395 | self::prepare_options( $results ); |
| 396 | 396 | |
| 397 | 397 | return stripslashes_deep( $results ); |
| 398 | - } |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | 401 | * Get the field type by key or id |
@@ -403,26 +403,26 @@ discard block |
||
| 403 | 403 | * @param int|string The field id or key |
| 404 | 404 | * @param mixed $col The name of the column in the fields database table |
| 405 | 405 | */ |
| 406 | - public static function get_type( $id, $col = 'type' ) { |
|
| 407 | - $field = FrmDb::check_cache( $id, 'frm_field' ); |
|
| 408 | - if ( $field ) { |
|
| 409 | - $type = $field->{$col}; |
|
| 410 | - } else { |
|
| 406 | + public static function get_type( $id, $col = 'type' ) { |
|
| 407 | + $field = FrmDb::check_cache( $id, 'frm_field' ); |
|
| 408 | + if ( $field ) { |
|
| 409 | + $type = $field->{$col}; |
|
| 410 | + } else { |
|
| 411 | 411 | $where = array( |
| 412 | 412 | 'or' => 1, |
| 413 | 413 | 'id' => $id, |
| 414 | 414 | 'field_key' => $id, |
| 415 | 415 | ); |
| 416 | 416 | $type = FrmDb::get_var( 'frm_fields', $where, $col ); |
| 417 | - } |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - return $type; |
|
| 420 | - } |
|
| 419 | + return $type; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | 422 | public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) { |
| 423 | - if ( ! $form_id ) { |
|
| 424 | - return array(); |
|
| 425 | - } |
|
| 423 | + if ( ! $form_id ) { |
|
| 424 | + return array(); |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | 427 | $results = self::get_fields_from_transients( |
| 428 | 428 | $form_id, |
@@ -432,30 +432,30 @@ discard block |
||
| 432 | 432 | ) |
| 433 | 433 | ); |
| 434 | 434 | if ( ! empty( $results ) ) { |
| 435 | - $fields = array(); |
|
| 436 | - $count = 0; |
|
| 437 | - foreach ( $results as $result ) { |
|
| 438 | - if ( $type != $result->type ) { |
|
| 439 | - continue; |
|
| 440 | - } |
|
| 435 | + $fields = array(); |
|
| 436 | + $count = 0; |
|
| 437 | + foreach ( $results as $result ) { |
|
| 438 | + if ( $type != $result->type ) { |
|
| 439 | + continue; |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | $fields[ $result->id ] = $result; |
| 443 | - $count++; |
|
| 444 | - if ( $limit == 1 ) { |
|
| 445 | - $fields = $result; |
|
| 446 | - break; |
|
| 447 | - } |
|
| 443 | + $count++; |
|
| 444 | + if ( $limit == 1 ) { |
|
| 445 | + $fields = $result; |
|
| 446 | + break; |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | 449 | if ( ! empty( $limit ) && $count >= $limit ) { |
| 450 | - break; |
|
| 451 | - } |
|
| 450 | + break; |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | 453 | unset( $result ); |
| 454 | 454 | } |
| 455 | 455 | return stripslashes_deep( $fields ); |
| 456 | - } |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | - self::$use_cache = false; |
|
| 458 | + self::$use_cache = false; |
|
| 459 | 459 | |
| 460 | 460 | $where = array( |
| 461 | 461 | 'fi.form_id' => (int) $form_id, |
@@ -463,59 +463,59 @@ discard block |
||
| 463 | 463 | ); |
| 464 | 464 | self::maybe_include_repeating_fields( $inc_sub, $where ); |
| 465 | 465 | $results = self::getAll( $where, 'field_order', $limit ); |
| 466 | - self::$use_cache = true; |
|
| 466 | + self::$use_cache = true; |
|
| 467 | 467 | self::include_sub_fields( $results, $inc_sub, $type ); |
| 468 | 468 | |
| 469 | - return $results; |
|
| 470 | - } |
|
| 469 | + return $results; |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | 472 | public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) { |
| 473 | - if ( ! (int) $form_id ) { |
|
| 474 | - return array(); |
|
| 475 | - } |
|
| 473 | + if ( ! (int) $form_id ) { |
|
| 474 | + return array(); |
|
| 475 | + } |
|
| 476 | 476 | |
| 477 | 477 | $results = self::get_fields_from_transients( $form_id, compact( 'inc_embed', 'inc_repeat' ) ); |
| 478 | 478 | if ( ! empty( $results ) ) { |
| 479 | 479 | if ( empty( $limit ) ) { |
| 480 | 480 | return $results; |
| 481 | - } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - $fields = array(); |
|
| 484 | - $count = 0; |
|
| 485 | - foreach ( $results as $result ) { |
|
| 483 | + $fields = array(); |
|
| 484 | + $count = 0; |
|
| 485 | + foreach ( $results as $result ) { |
|
| 486 | 486 | $count++; |
| 487 | 487 | $fields[ $result->id ] = $result; |
| 488 | 488 | if ( ! empty( $limit ) && $count >= $limit ) { |
| 489 | - break; |
|
| 490 | - } |
|
| 491 | - } |
|
| 489 | + break; |
|
| 490 | + } |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | 493 | return $fields; |
| 494 | - } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - self::$use_cache = false; |
|
| 496 | + self::$use_cache = false; |
|
| 497 | 497 | |
| 498 | 498 | $where = array( 'fi.form_id' => absint( $form_id ) ); |
| 499 | 499 | self::maybe_include_repeating_fields( $inc_repeat, $where ); |
| 500 | 500 | $results = self::getAll( $where, 'field_order', $limit ); |
| 501 | 501 | |
| 502 | - self::$use_cache = true; |
|
| 502 | + self::$use_cache = true; |
|
| 503 | 503 | |
| 504 | 504 | self::include_sub_fields( $results, $inc_embed, 'all' ); |
| 505 | 505 | |
| 506 | 506 | if ( empty( $limit ) ) { |
| 507 | 507 | self::set_field_transient( $results, $form_id, 0, compact( 'inc_embed', 'inc_repeat' ) ); |
| 508 | - } |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | 510 | return $results; |
| 511 | - } |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | 513 | /** |
| 514 | - * If repeating fields should be included, adjust $where accordingly |
|
| 515 | - * |
|
| 516 | - * @param string $inc_repeat |
|
| 517 | - * @param array $where - pass by reference |
|
| 518 | - */ |
|
| 514 | + * If repeating fields should be included, adjust $where accordingly |
|
| 515 | + * |
|
| 516 | + * @param string $inc_repeat |
|
| 517 | + * @param array $where - pass by reference |
|
| 518 | + */ |
|
| 519 | 519 | private static function maybe_include_repeating_fields( $inc_repeat, &$where ) { |
| 520 | 520 | if ( $inc_repeat == 'include' ) { |
| 521 | 521 | $form_id = $where['fi.form_id']; |
@@ -530,21 +530,21 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) { |
| 532 | 532 | if ( 'include' != $inc_embed || empty( $results ) ) { |
| 533 | - return; |
|
| 534 | - } |
|
| 533 | + return; |
|
| 534 | + } |
|
| 535 | 535 | |
| 536 | - $form_fields = $results; |
|
| 536 | + $form_fields = $results; |
|
| 537 | 537 | $index_offset = 1; |
| 538 | - foreach ( $form_fields as $k => $field ) { |
|
| 538 | + foreach ( $form_fields as $k => $field ) { |
|
| 539 | 539 | if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) { |
| 540 | - continue; |
|
| 541 | - } |
|
| 540 | + continue; |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | - if ( $type == 'all' ) { |
|
| 544 | - $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
| 545 | - } else { |
|
| 543 | + if ( $type == 'all' ) { |
|
| 544 | + $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
| 545 | + } else { |
|
| 546 | 546 | $sub_fields = self::get_all_types_in_form( $field->form_id, $type ); |
| 547 | - } |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | 549 | if ( ! empty( $sub_fields ) ) { |
| 550 | 550 | $index = $k + $index_offset; |
@@ -552,35 +552,35 @@ discard block |
||
| 552 | 552 | array_splice( $results, $index, 0, $sub_fields ); |
| 553 | 553 | } |
| 554 | 554 | unset( $field, $sub_fields ); |
| 555 | - } |
|
| 556 | - } |
|
| 555 | + } |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | 558 | public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) { |
| 559 | 559 | $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id; |
| 560 | - if ( self::$use_cache ) { |
|
| 561 | - // make sure old cache doesn't get saved as a transient |
|
| 560 | + if ( self::$use_cache ) { |
|
| 561 | + // make sure old cache doesn't get saved as a transient |
|
| 562 | 562 | $results = wp_cache_get( $cache_key, 'frm_field' ); |
| 563 | - if ( false !== $results ) { |
|
| 563 | + if ( false !== $results ) { |
|
| 564 | 564 | return stripslashes_deep( $results ); |
| 565 | - } |
|
| 566 | - } |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - global $wpdb; |
|
| 568 | + global $wpdb; |
|
| 569 | 569 | |
| 570 | - if ( $blog_id && is_multisite() ) { |
|
| 571 | - global $wpmuBaseTablePrefix; |
|
| 572 | - if ( $wpmuBaseTablePrefix ) { |
|
| 570 | + if ( $blog_id && is_multisite() ) { |
|
| 571 | + global $wpmuBaseTablePrefix; |
|
| 572 | + if ( $wpmuBaseTablePrefix ) { |
|
| 573 | 573 | $prefix = $wpmuBaseTablePrefix . $blog_id . '_'; |
| 574 | - } else { |
|
| 575 | - $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
| 576 | - } |
|
| 574 | + } else { |
|
| 575 | + $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | 578 | $table_name = $prefix . 'frm_fields'; |
| 579 | 579 | $form_table_name = $prefix . 'frm_forms'; |
| 580 | 580 | } else { |
| 581 | 581 | $table_name = $wpdb->prefix . 'frm_fields'; |
| 582 | 582 | $form_table_name = $wpdb->prefix . 'frm_forms'; |
| 583 | - } |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | 585 | if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) { |
| 586 | 586 | $order_by = ' ORDER BY ' . $order_by; |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | $limit = FrmDb::esc_limit( $limit ); |
| 590 | 590 | |
| 591 | - $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
| 592 | - $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
| 591 | + $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
| 592 | + $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
| 593 | 593 | |
| 594 | 594 | if ( is_array( $where ) ) { |
| 595 | 595 | $args = array( |
@@ -603,8 +603,8 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results'; |
| 605 | 605 | $results = $wpdb->$function_name( $query ); |
| 606 | - } |
|
| 607 | - unset( $where ); |
|
| 606 | + } |
|
| 607 | + unset( $where ); |
|
| 608 | 608 | |
| 609 | 609 | self::format_field_results( $results ); |
| 610 | 610 | |
@@ -857,8 +857,8 @@ discard block |
||
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
| 860 | - * @since 2.0.09 |
|
| 861 | - */ |
|
| 860 | + * @since 2.0.09 |
|
| 861 | + */ |
|
| 862 | 862 | public static function is_repeating_field( $field ) { |
| 863 | 863 | if ( is_array( $field ) ) { |
| 864 | 864 | $is_repeating_field = ( 'divider' == $field['type'] ); |
@@ -868,14 +868,14 @@ discard block |
||
| 868 | 868 | return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) ); |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - /** |
|
| 872 | - * @param string $key |
|
| 873 | - * @return int field id |
|
| 874 | - */ |
|
| 871 | + /** |
|
| 872 | + * @param string $key |
|
| 873 | + * @return int field id |
|
| 874 | + */ |
|
| 875 | 875 | public static function get_id_by_key( $key ) { |
| 876 | - $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
| 877 | - return $id; |
|
| 878 | - } |
|
| 876 | + $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
| 877 | + return $id; |
|
| 878 | + } |
|
| 879 | 879 | |
| 880 | 880 | /** |
| 881 | 881 | * @param string $id |
@@ -1,18 +1,18 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmEntryValidate { |
| 4 | - public static function validate( $values, $exclude = false ) { |
|
| 5 | - FrmEntry::sanitize_entry_post( $values ); |
|
| 6 | - $errors = array(); |
|
| 4 | + public static function validate( $values, $exclude = false ) { |
|
| 5 | + FrmEntry::sanitize_entry_post( $values ); |
|
| 6 | + $errors = array(); |
|
| 7 | 7 | |
| 8 | 8 | if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
| 9 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 10 | - return $errors; |
|
| 11 | - } |
|
| 9 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 10 | + return $errors; |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | 13 | 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' ) ) ) { |
| 14 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 15 | - } |
|
| 14 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | self::set_item_key( $values ); |
| 18 | 18 | |
@@ -57,24 +57,24 @@ discard block |
||
| 57 | 57 | return FrmField::getAll( $where, 'field_order' ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 61 | - $defaults = array( |
|
| 62 | - 'id' => $posted_field->id, |
|
| 63 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 64 | - 'key_pointer' => '', // the pointer in the posted array |
|
| 65 | - 'exclude' => array(), // exclude these field types from validation |
|
| 66 | - ); |
|
| 67 | - $args = wp_parse_args( $args, $defaults ); |
|
| 60 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 61 | + $defaults = array( |
|
| 62 | + 'id' => $posted_field->id, |
|
| 63 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 64 | + 'key_pointer' => '', // the pointer in the posted array |
|
| 65 | + 'exclude' => array(), // exclude these field types from validation |
|
| 66 | + ); |
|
| 67 | + $args = wp_parse_args( $args, $defaults ); |
|
| 68 | 68 | |
| 69 | 69 | if ( empty( $args['parent_field_id'] ) ) { |
| 70 | 70 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
| 71 | - } else { |
|
| 72 | - // value is from a nested form |
|
| 73 | - $value = $values; |
|
| 74 | - } |
|
| 71 | + } else { |
|
| 72 | + // value is from a nested form |
|
| 73 | + $value = $values; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - // Check for values in "Other" fields |
|
| 77 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 76 | + // Check for values in "Other" fields |
|
| 77 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 78 | 78 | |
| 79 | 79 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
| 80 | 80 | |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | $value = trim( $value ); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) { |
|
| 90 | + if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) { |
|
| 91 | 91 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
| 92 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { // WPCS: CSRF ok. |
|
| 93 | - $_POST['item_name'] = $value; |
|
| 94 | - } |
|
| 92 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { // WPCS: CSRF ok. |
|
| 93 | + $_POST['item_name'] = $value; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
| 97 | 97 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
| 105 | 105 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
| 106 | - } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) { |
| 109 | 109 | $is_default = ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ); |
@@ -213,26 +213,26 @@ discard block |
||
| 213 | 213 | * @param array $values |
| 214 | 214 | * @param array $errors by reference |
| 215 | 215 | */ |
| 216 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
| 217 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 218 | - // only check spam if there are no other errors |
|
| 219 | - return; |
|
| 220 | - } |
|
| 216 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
| 217 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 218 | + // only check spam if there are no other errors |
|
| 219 | + return; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | 222 | if ( self::is_honeypot_spam() || self::is_spam_bot() ) { |
| 223 | 223 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( self::blacklist_check( $values ) ) { |
|
| 227 | - $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' ); |
|
| 228 | - } |
|
| 226 | + if ( self::blacklist_check( $values ) ) { |
|
| 227 | + $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' ); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - if ( self::is_akismet_spam( $values ) ) { |
|
| 230 | + if ( self::is_akismet_spam( $values ) ) { |
|
| 231 | 231 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
| 232 | 232 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
| 233 | 233 | } |
| 234 | - } |
|
| 235 | - } |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | private static function is_honeypot_spam() { |
| 238 | 238 | $honeypot_value = FrmAppHelper::get_param( 'frm_verify', '', 'get', 'sanitize_text_field' ); |
@@ -254,15 +254,15 @@ discard block |
||
| 254 | 254 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - public static function blacklist_check( $values ) { |
|
| 257 | + public static function blacklist_check( $values ) { |
|
| 258 | 258 | if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
| 259 | - return false; |
|
| 260 | - } |
|
| 259 | + return false; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 263 | - if ( empty( $mod_keys ) ) { |
|
| 264 | - return false; |
|
| 265 | - } |
|
| 262 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 263 | + if ( empty( $mod_keys ) ) { |
|
| 264 | + return false; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | 267 | $content = FrmEntriesHelper::entry_array_to_string( $values ); |
| 268 | 268 | if ( empty( $content ) ) { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $user_info = self::get_spam_check_user_info( $values ); |
| 275 | 275 | |
| 276 | 276 | return wp_blacklist_check( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent ); |
| 277 | - } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | 280 | * Check entries for Akismet spam |
@@ -6,11 +6,11 @@ discard block |
||
| 6 | 6 | class FrmEntry { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | - * Create a new entry |
|
| 10 | - * |
|
| 11 | - * @param array $values |
|
| 12 | - * @return int | boolean $entry_id |
|
| 13 | - */ |
|
| 9 | + * Create a new entry |
|
| 10 | + * |
|
| 11 | + * @param array $values |
|
| 12 | + * @return int | boolean $entry_id |
|
| 13 | + */ |
|
| 14 | 14 | public static function create( $values ) { |
| 15 | 15 | $entry_id = self::create_entry( $values, 'standard' ); |
| 16 | 16 | |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * Create a new entry with some differences depending on type |
|
| 22 | - * |
|
| 23 | - * @param array $values |
|
| 24 | - * @param string $type |
|
| 25 | - * @return int | boolean $entry_id |
|
| 26 | - */ |
|
| 21 | + * Create a new entry with some differences depending on type |
|
| 22 | + * |
|
| 23 | + * @param array $values |
|
| 24 | + * @param string $type |
|
| 25 | + * @return int | boolean $entry_id |
|
| 26 | + */ |
|
| 27 | 27 | private static function create_entry( $values, $type ) { |
| 28 | 28 | $new_values = self::before_insert_entry_in_database( $values, $type ); |
| 29 | 29 | |
@@ -49,40 +49,40 @@ discard block |
||
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $check_val = $new_values; |
|
| 52 | + $check_val = $new_values; |
|
| 53 | 53 | $check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) ); |
| 54 | 54 | |
| 55 | 55 | unset( $check_val['created_at'], $check_val['updated_at'] ); |
| 56 | 56 | unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] ); |
| 57 | 57 | |
| 58 | - if ( $new_values['item_key'] == $new_values['name'] ) { |
|
| 58 | + if ( $new_values['item_key'] == $new_values['name'] ) { |
|
| 59 | 59 | unset( $check_val['name'] ); |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - global $wpdb; |
|
| 62 | + global $wpdb; |
|
| 63 | 63 | $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) ); |
| 64 | 64 | |
| 65 | 65 | if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) { |
| 66 | - return false; |
|
| 67 | - } |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $is_duplicate = false; |
|
| 70 | - foreach ( $entry_exists as $entry_exist ) { |
|
| 71 | - $is_duplicate = true; |
|
| 69 | + $is_duplicate = false; |
|
| 70 | + foreach ( $entry_exists as $entry_exist ) { |
|
| 71 | + $is_duplicate = true; |
|
| 72 | 72 | |
| 73 | 73 | // make sure it's a duplicate |
| 74 | 74 | $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist ); |
| 75 | - $field_metas = array(); |
|
| 76 | - foreach ( $metas as $meta ) { |
|
| 75 | + $field_metas = array(); |
|
| 76 | + foreach ( $metas as $meta ) { |
|
| 77 | 77 | $field_metas[ $meta->field_id ] = $meta->meta_value; |
| 78 | - } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - // If prev entry is empty and current entry is not, they are not duplicates |
|
| 81 | - $filtered_vals = array_filter( $values['item_meta'] ); |
|
| 80 | + // If prev entry is empty and current entry is not, they are not duplicates |
|
| 81 | + $filtered_vals = array_filter( $values['item_meta'] ); |
|
| 82 | 82 | $field_metas = array_filter( $field_metas ); |
| 83 | - if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 83 | + if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | // compare serialized values and not arrays |
| 88 | 88 | $new_meta = array_map( 'maybe_serialize', $filtered_vals ); |
@@ -99,20 +99,20 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $diff = array_diff_assoc( $field_metas, $new_meta ); |
| 102 | - foreach ( $diff as $field_id => $meta_value ) { |
|
| 102 | + foreach ( $diff as $field_id => $meta_value ) { |
|
| 103 | 103 | if ( ! empty( $meta_value ) ) { |
| 104 | - $is_duplicate = false; |
|
| 105 | - continue; |
|
| 106 | - } |
|
| 107 | - } |
|
| 104 | + $is_duplicate = false; |
|
| 105 | + continue; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if ( $is_duplicate ) { |
|
| 109 | + if ( $is_duplicate ) { |
|
| 110 | 110 | break; |
| 111 | - } |
|
| 112 | - } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return $is_duplicate; |
|
| 115 | - } |
|
| 114 | + return $is_duplicate; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Determine if an entry needs to be checked as a possible duplicate |
@@ -157,32 +157,32 @@ discard block |
||
| 157 | 157 | $new_values['updated_at'] = $new_values['created_at']; |
| 158 | 158 | |
| 159 | 159 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
| 160 | - if ( ! $query_results ) { |
|
| 161 | - return false; |
|
| 162 | - } |
|
| 160 | + if ( ! $query_results ) { |
|
| 161 | + return false; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - $entry_id = $wpdb->insert_id; |
|
| 164 | + $entry_id = $wpdb->insert_id; |
|
| 165 | 165 | |
| 166 | - global $frm_vars; |
|
| 166 | + global $frm_vars; |
|
| 167 | 167 | if ( ! isset( $frm_vars['saved_entries'] ) ) { |
| 168 | - $frm_vars['saved_entries'] = array(); |
|
| 169 | - } |
|
| 170 | - $frm_vars['saved_entries'][] = (int) $entry_id; |
|
| 168 | + $frm_vars['saved_entries'] = array(); |
|
| 169 | + } |
|
| 170 | + $frm_vars['saved_entries'][] = (int) $entry_id; |
|
| 171 | 171 | |
| 172 | 172 | FrmEntryMeta::duplicate_entry_metas( $id, $entry_id ); |
| 173 | 173 | self::clear_cache(); |
| 174 | 174 | |
| 175 | 175 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
| 176 | - return $entry_id; |
|
| 177 | - } |
|
| 176 | + return $entry_id; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | - * Update an entry (not via XML) |
|
| 181 | - * |
|
| 182 | - * @param int $id |
|
| 183 | - * @param array $values |
|
| 184 | - * @return boolean|int $update_results |
|
| 185 | - */ |
|
| 180 | + * Update an entry (not via XML) |
|
| 181 | + * |
|
| 182 | + * @param int $id |
|
| 183 | + * @param array $values |
|
| 184 | + * @return boolean|int $update_results |
|
| 185 | + */ |
|
| 186 | 186 | public static function update( $id, $values ) { |
| 187 | 187 | $update_results = self::update_entry( $id, $values, 'standard' ); |
| 188 | 188 | |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | - * Update an entry with some differences depending on the update type |
|
| 194 | - * |
|
| 195 | - * @since 2.0.16 |
|
| 196 | - * |
|
| 197 | - * @param int $id |
|
| 198 | - * @param array $values |
|
| 199 | - * @return boolean|int $query_results |
|
| 200 | - */ |
|
| 193 | + * Update an entry with some differences depending on the update type |
|
| 194 | + * |
|
| 195 | + * @since 2.0.16 |
|
| 196 | + * |
|
| 197 | + * @param int $id |
|
| 198 | + * @param array $values |
|
| 199 | + * @return boolean|int $query_results |
|
| 200 | + */ |
|
| 201 | 201 | private static function update_entry( $id, $values, $update_type ) { |
| 202 | 202 | global $wpdb; |
| 203 | 203 | |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | public static function destroy( $id ) { |
| 219 | - global $wpdb; |
|
| 220 | - $id = (int) $id; |
|
| 219 | + global $wpdb; |
|
| 220 | + $id = (int) $id; |
|
| 221 | 221 | |
| 222 | 222 | $entry = self::getOne( $id ); |
| 223 | - if ( ! $entry ) { |
|
| 224 | - $result = false; |
|
| 225 | - return $result; |
|
| 226 | - } |
|
| 223 | + if ( ! $entry ) { |
|
| 224 | + $result = false; |
|
| 225 | + return $result; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | do_action( 'frm_before_destroy_entry', $id, $entry ); |
| 229 | 229 | |
@@ -232,18 +232,18 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | self::clear_cache(); |
| 234 | 234 | |
| 235 | - return $result; |
|
| 236 | - } |
|
| 235 | + return $result; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | 238 | public static function update_form( $id, $value, $form_id ) { |
| 239 | - global $wpdb; |
|
| 239 | + global $wpdb; |
|
| 240 | 240 | $form_id = isset( $value ) ? $form_id : null; |
| 241 | 241 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
| 242 | 242 | if ( $result ) { |
| 243 | 243 | self::clear_cache(); |
| 244 | 244 | } |
| 245 | - return $result; |
|
| 246 | - } |
|
| 245 | + return $result; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | 249 | * Clear entry caching |
@@ -287,19 +287,19 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | public static function getOne( $id, $meta = false ) { |
| 290 | - global $wpdb; |
|
| 290 | + global $wpdb; |
|
| 291 | 291 | |
| 292 | - $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
| 292 | + $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
| 293 | 293 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
| 294 | 294 | |
| 295 | 295 | $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s'; |
| 296 | - $query_args = array( $id ); |
|
| 297 | - $query = $wpdb->prepare( $query, $query_args ); // WPCS: unprepared SQL ok. |
|
| 296 | + $query_args = array( $id ); |
|
| 297 | + $query = $wpdb->prepare( $query, $query_args ); // WPCS: unprepared SQL ok. |
|
| 298 | 298 | |
| 299 | - if ( ! $meta ) { |
|
| 299 | + if ( ! $meta ) { |
|
| 300 | 300 | $entry = FrmDb::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
| 301 | 301 | return stripslashes_deep( $entry ); |
| 302 | - } |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | 304 | $entry = FrmDb::check_cache( $id, 'frm_entry' ); |
| 305 | 305 | if ( $entry !== false ) { |
@@ -310,14 +310,14 @@ discard block |
||
| 310 | 310 | $entry = self::get_meta( $entry ); |
| 311 | 311 | |
| 312 | 312 | return stripslashes_deep( $entry ); |
| 313 | - } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | public static function get_meta( $entry ) { |
| 316 | - if ( ! $entry ) { |
|
| 317 | - return $entry; |
|
| 318 | - } |
|
| 316 | + if ( ! $entry ) { |
|
| 317 | + return $entry; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - global $wpdb; |
|
| 320 | + global $wpdb; |
|
| 321 | 321 | $metas = FrmDb::get_results( |
| 322 | 322 | $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', |
| 323 | 323 | array( |
@@ -327,56 +327,56 @@ discard block |
||
| 327 | 327 | 'field_id, meta_value, field_key, item_id' |
| 328 | 328 | ); |
| 329 | 329 | |
| 330 | - $entry->metas = array(); |
|
| 330 | + $entry->metas = array(); |
|
| 331 | 331 | |
| 332 | 332 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
| 333 | - foreach ( $metas as $meta_val ) { |
|
| 334 | - if ( $meta_val->item_id == $entry->id ) { |
|
| 333 | + foreach ( $metas as $meta_val ) { |
|
| 334 | + if ( $meta_val->item_id == $entry->id ) { |
|
| 335 | 335 | $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
| 336 | 336 | if ( $include_key ) { |
| 337 | 337 | $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
| 338 | 338 | } |
| 339 | - continue; |
|
| 340 | - } |
|
| 339 | + continue; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - // include sub entries in an array |
|
| 342 | + // include sub entries in an array |
|
| 343 | 343 | if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
| 344 | 344 | $entry->metas[ $meta_val->field_id ] = array(); |
| 345 | - } |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | 347 | $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
| 348 | 348 | |
| 349 | 349 | unset( $meta_val ); |
| 350 | - } |
|
| 350 | + } |
|
| 351 | 351 | unset( $metas ); |
| 352 | 352 | |
| 353 | 353 | FrmDb::set_cache( $entry->id, $entry, 'frm_entry' ); |
| 354 | 354 | |
| 355 | - return $entry; |
|
| 356 | - } |
|
| 355 | + return $entry; |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - /** |
|
| 359 | - * @param string $id |
|
| 360 | - */ |
|
| 358 | + /** |
|
| 359 | + * @param string $id |
|
| 360 | + */ |
|
| 361 | 361 | public static function exists( $id ) { |
| 362 | - global $wpdb; |
|
| 362 | + global $wpdb; |
|
| 363 | 363 | |
| 364 | - if ( FrmDb::check_cache( $id, 'frm_entry' ) ) { |
|
| 365 | - $exists = true; |
|
| 366 | - return $exists; |
|
| 367 | - } |
|
| 364 | + if ( FrmDb::check_cache( $id, 'frm_entry' ) ) { |
|
| 365 | + $exists = true; |
|
| 366 | + return $exists; |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | 369 | if ( is_numeric( $id ) ) { |
| 370 | - $where = array( 'id' => $id ); |
|
| 371 | - } else { |
|
| 372 | - $where = array( 'item_key' => $id ); |
|
| 373 | - } |
|
| 370 | + $where = array( 'id' => $id ); |
|
| 371 | + } else { |
|
| 372 | + $where = array( 'item_key' => $id ); |
|
| 373 | + } |
|
| 374 | 374 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
| 375 | 375 | |
| 376 | 376 | return ( $id && $id > 0 ); |
| 377 | - } |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
| 379 | + public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
| 380 | 380 | global $wpdb; |
| 381 | 381 | |
| 382 | 382 | $limit = FrmDb::esc_limit( $limit ); |
@@ -384,21 +384,21 @@ discard block |
||
| 384 | 384 | $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form; |
| 385 | 385 | $entries = wp_cache_get( $cache_key, 'frm_entry' ); |
| 386 | 386 | |
| 387 | - if ( false === $entries ) { |
|
| 388 | - $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
|
| 387 | + if ( false === $entries ) { |
|
| 388 | + $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
|
| 389 | 389 | $table = $wpdb->prefix . 'frm_items it '; |
| 390 | 390 | |
| 391 | - if ( $inc_form ) { |
|
| 392 | - $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
| 393 | - $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
| 394 | - } |
|
| 391 | + if ( $inc_form ) { |
|
| 392 | + $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
| 393 | + $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
| 397 | - // sort by a requested field |
|
| 398 | - $field_id = (int) $order_matches[1]; |
|
| 396 | + if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
| 397 | + // sort by a requested field |
|
| 398 | + $field_id = (int) $order_matches[1]; |
|
| 399 | 399 | $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id; |
| 400 | 400 | unset( $order_matches, $field_id ); |
| 401 | - } |
|
| 401 | + } |
|
| 402 | 402 | |
| 403 | 403 | // prepare the query |
| 404 | 404 | $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
@@ -407,45 +407,45 @@ discard block |
||
| 407 | 407 | unset( $query ); |
| 408 | 408 | |
| 409 | 409 | FrmDb::set_cache( $cache_key, $entries, 'frm_entry' ); |
| 410 | - } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - if ( ! $meta || ! $entries ) { |
|
| 412 | + if ( ! $meta || ! $entries ) { |
|
| 413 | 413 | return stripslashes_deep( $entries ); |
| 414 | - } |
|
| 414 | + } |
|
| 415 | 415 | unset( $meta ); |
| 416 | 416 | |
| 417 | 417 | if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) { |
| 418 | 418 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
| 419 | - } |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | - $meta_where = array( 'field_id !' => 0 ); |
|
| 421 | + $meta_where = array( 'field_id !' => 0 ); |
|
| 422 | 422 | if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
| 423 | - $meta_where['fi.form_id'] = $where['it.form_id']; |
|
| 424 | - } else { |
|
| 425 | - $meta_where['item_id'] = array_keys( $entries ); |
|
| 426 | - } |
|
| 423 | + $meta_where['fi.form_id'] = $where['it.form_id']; |
|
| 424 | + } else { |
|
| 425 | + $meta_where['item_id'] = array_keys( $entries ); |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | - $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' ); |
|
| 428 | + $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' ); |
|
| 429 | 429 | |
| 430 | - unset( $meta_where ); |
|
| 430 | + unset( $meta_where ); |
|
| 431 | 431 | |
| 432 | - if ( ! $metas ) { |
|
| 432 | + if ( ! $metas ) { |
|
| 433 | 433 | return stripslashes_deep( $entries ); |
| 434 | - } |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | - foreach ( $metas as $m_key => $meta_val ) { |
|
| 437 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 438 | - continue; |
|
| 439 | - } |
|
| 436 | + foreach ( $metas as $m_key => $meta_val ) { |
|
| 437 | + if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 438 | + continue; |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 441 | + if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 442 | 442 | $entries[ $meta_val->item_id ]->metas = array(); |
| 443 | - } |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
| 446 | 446 | |
| 447 | 447 | unset( $m_key, $meta_val ); |
| 448 | - } |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | if ( ! FrmAppHelper::prevent_caching() ) { |
| 451 | 451 | foreach ( $entries as $entry ) { |
@@ -455,30 +455,30 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | return stripslashes_deep( $entries ); |
| 458 | - } |
|
| 458 | + } |
|
| 459 | 459 | |
| 460 | - // Pagination Methods |
|
| 461 | - public static function getRecordCount( $where = '' ) { |
|
| 462 | - global $wpdb; |
|
| 460 | + // Pagination Methods |
|
| 461 | + public static function getRecordCount( $where = '' ) { |
|
| 462 | + global $wpdb; |
|
| 463 | 463 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
| 464 | 464 | |
| 465 | 465 | if ( is_numeric( $where ) ) { |
| 466 | - $table_join = 'frm_items'; |
|
| 467 | - $where = array( 'form_id' => $where ); |
|
| 468 | - } |
|
| 466 | + $table_join = 'frm_items'; |
|
| 467 | + $where = array( 'form_id' => $where ); |
|
| 468 | + } |
|
| 469 | 469 | |
| 470 | - if ( is_array( $where ) ) { |
|
| 471 | - $count = FrmDb::get_count( $table_join, $where ); |
|
| 472 | - } else { |
|
| 470 | + if ( is_array( $where ) ) { |
|
| 471 | + $count = FrmDb::get_count( $table_join, $where ); |
|
| 472 | + } else { |
|
| 473 | 473 | $cache_key = 'count_' . maybe_serialize( $where ); |
| 474 | 474 | $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmDb::prepend_and_or_where( ' WHERE ', $where ); |
| 475 | 475 | $count = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_var' ); |
| 476 | - } |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - return $count; |
|
| 479 | - } |
|
| 478 | + return $count; |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - public static function getPageCount( $p_size, $where = '' ) { |
|
| 481 | + public static function getPageCount( $p_size, $where = '' ) { |
|
| 482 | 482 | $p_size = (int) $p_size; |
| 483 | 483 | $count = 1; |
| 484 | 484 | if ( $p_size ) { |
@@ -489,16 +489,16 @@ discard block |
||
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | return $count; |
| 492 | - } |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | 494 | /** |
| 495 | - * Prepare the data before inserting it into the database |
|
| 496 | - * |
|
| 497 | - * @since 2.0.16 |
|
| 498 | - * @param array $values |
|
| 499 | - * @param string $type |
|
| 500 | - * @return array $new_values |
|
| 501 | - */ |
|
| 495 | + * Prepare the data before inserting it into the database |
|
| 496 | + * |
|
| 497 | + * @since 2.0.16 |
|
| 498 | + * @param array $values |
|
| 499 | + * @param string $type |
|
| 500 | + * @return array $new_values |
|
| 501 | + */ |
|
| 502 | 502 | private static function before_insert_entry_in_database( &$values, $type ) { |
| 503 | 503 | |
| 504 | 504 | self::sanitize_entry_post( $values ); |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** |
| 516 | - * Create an entry and perform after create actions |
|
| 517 | - * |
|
| 518 | - * @since 2.0.16 |
|
| 519 | - * @param array $values |
|
| 520 | - * @param array $new_values |
|
| 521 | - * @return boolean|int $entry_id |
|
| 522 | - */ |
|
| 516 | + * Create an entry and perform after create actions |
|
| 517 | + * |
|
| 518 | + * @since 2.0.16 |
|
| 519 | + * @param array $values |
|
| 520 | + * @param array $new_values |
|
| 521 | + * @return boolean|int $entry_id |
|
| 522 | + */ |
|
| 523 | 523 | private static function continue_to_create_entry( $values, $new_values ) { |
| 524 | 524 | $entry_id = self::insert_entry_into_database( $new_values ); |
| 525 | 525 | if ( ! $entry_id ) { |
@@ -531,37 +531,37 @@ discard block |
||
| 531 | 531 | return $entry_id; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - /** |
|
| 535 | - * Sanitize the POST values before we use them |
|
| 536 | - * |
|
| 537 | - * @since 2.0 |
|
| 538 | - * @param array $values The POST values by reference |
|
| 539 | - */ |
|
| 540 | - public static function sanitize_entry_post( &$values ) { |
|
| 541 | - $sanitize_method = array( |
|
| 542 | - 'form_id' => 'absint', |
|
| 543 | - 'frm_action' => 'sanitize_title', |
|
| 544 | - 'form_key' => 'sanitize_title', |
|
| 545 | - 'item_key' => 'sanitize_title', |
|
| 546 | - 'item_name' => 'sanitize_text_field', |
|
| 547 | - 'frm_saving_draft' => 'absint', |
|
| 548 | - 'is_draft' => 'absint', |
|
| 549 | - 'post_id' => 'absint', |
|
| 550 | - 'parent_item_id' => 'absint', |
|
| 551 | - 'created_at' => 'sanitize_text_field', |
|
| 552 | - 'updated_at' => 'sanitize_text_field', |
|
| 553 | - ); |
|
| 554 | - |
|
| 555 | - FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
| 556 | - } |
|
| 534 | + /** |
|
| 535 | + * Sanitize the POST values before we use them |
|
| 536 | + * |
|
| 537 | + * @since 2.0 |
|
| 538 | + * @param array $values The POST values by reference |
|
| 539 | + */ |
|
| 540 | + public static function sanitize_entry_post( &$values ) { |
|
| 541 | + $sanitize_method = array( |
|
| 542 | + 'form_id' => 'absint', |
|
| 543 | + 'frm_action' => 'sanitize_title', |
|
| 544 | + 'form_key' => 'sanitize_title', |
|
| 545 | + 'item_key' => 'sanitize_title', |
|
| 546 | + 'item_name' => 'sanitize_text_field', |
|
| 547 | + 'frm_saving_draft' => 'absint', |
|
| 548 | + 'is_draft' => 'absint', |
|
| 549 | + 'post_id' => 'absint', |
|
| 550 | + 'parent_item_id' => 'absint', |
|
| 551 | + 'created_at' => 'sanitize_text_field', |
|
| 552 | + 'updated_at' => 'sanitize_text_field', |
|
| 553 | + ); |
|
| 554 | + |
|
| 555 | + FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | 558 | /** |
| 559 | - * Prepare the new values for inserting into the database |
|
| 560 | - * |
|
| 561 | - * @since 2.0.16 |
|
| 562 | - * @param array $values |
|
| 563 | - * @return array $new_values |
|
| 564 | - */ |
|
| 559 | + * Prepare the new values for inserting into the database |
|
| 560 | + * |
|
| 561 | + * @since 2.0.16 |
|
| 562 | + * @param array $values |
|
| 563 | + * @return array $new_values |
|
| 564 | + */ |
|
| 565 | 565 | private static function package_entry_data( &$values ) { |
| 566 | 566 | global $wpdb; |
| 567 | 567 | |
@@ -614,34 +614,34 @@ discard block |
||
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
| 617 | - * Get the is_draft value for a new entry |
|
| 618 | - * |
|
| 619 | - * @since 2.0.16 |
|
| 620 | - * @param array $values |
|
| 621 | - * @return int |
|
| 622 | - */ |
|
| 617 | + * Get the is_draft value for a new entry |
|
| 618 | + * |
|
| 619 | + * @since 2.0.16 |
|
| 620 | + * @param array $values |
|
| 621 | + * @return int |
|
| 622 | + */ |
|
| 623 | 623 | private static function get_is_draft_value( $values ) { |
| 624 | 624 | return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | /** |
| 628 | - * Get the created_at value for a new entry |
|
| 629 | - * |
|
| 630 | - * @since 2.0.16 |
|
| 631 | - * @param array $values |
|
| 632 | - * @return string |
|
| 633 | - */ |
|
| 628 | + * Get the created_at value for a new entry |
|
| 629 | + * |
|
| 630 | + * @since 2.0.16 |
|
| 631 | + * @param array $values |
|
| 632 | + * @return string |
|
| 633 | + */ |
|
| 634 | 634 | private static function get_created_at( $values ) { |
| 635 | 635 | return self::get_entry_value( $values, 'created_at', current_time( 'mysql', 1 ) ); |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | - * Get the updated_at value for a new entry |
|
| 640 | - * |
|
| 641 | - * @since 2.0.16 |
|
| 642 | - * @param array $values |
|
| 643 | - * @return string |
|
| 644 | - */ |
|
| 639 | + * Get the updated_at value for a new entry |
|
| 640 | + * |
|
| 641 | + * @since 2.0.16 |
|
| 642 | + * @param array $values |
|
| 643 | + * @return string |
|
| 644 | + */ |
|
| 645 | 645 | private static function get_updated_at( $values ) { |
| 646 | 646 | if ( isset( $values['updated_at'] ) ) { |
| 647 | 647 | $updated_at = $values['updated_at']; |
@@ -653,12 +653,12 @@ discard block |
||
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | /** |
| 656 | - * Get the description value for a new entry |
|
| 657 | - * |
|
| 658 | - * @since 2.0.16 |
|
| 659 | - * @param array $values |
|
| 660 | - * @return string |
|
| 661 | - */ |
|
| 656 | + * Get the description value for a new entry |
|
| 657 | + * |
|
| 658 | + * @since 2.0.16 |
|
| 659 | + * @param array $values |
|
| 660 | + * @return string |
|
| 661 | + */ |
|
| 662 | 662 | private static function get_entry_description( $values ) { |
| 663 | 663 | if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) { |
| 664 | 664 | $description = maybe_serialize( $values['description'] ); |
@@ -675,12 +675,12 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | - * Get the user_id value for a new entry |
|
| 679 | - * |
|
| 680 | - * @since 2.0.16 |
|
| 681 | - * @param array $values |
|
| 682 | - * @return int |
|
| 683 | - */ |
|
| 678 | + * Get the user_id value for a new entry |
|
| 679 | + * |
|
| 680 | + * @since 2.0.16 |
|
| 681 | + * @param array $values |
|
| 682 | + * @return int |
|
| 683 | + */ |
|
| 684 | 684 | private static function get_entry_user_id( $values ) { |
| 685 | 685 | if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) { |
| 686 | 686 | $user_id = $values['frm_user_id']; |
@@ -693,12 +693,12 @@ discard block |
||
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
| 696 | - * Insert new entry into the database |
|
| 697 | - * |
|
| 698 | - * @since 2.0.16 |
|
| 699 | - * @param array $new_values |
|
| 700 | - * @return int | boolean $entry_id |
|
| 701 | - */ |
|
| 696 | + * Insert new entry into the database |
|
| 697 | + * |
|
| 698 | + * @since 2.0.16 |
|
| 699 | + * @param array $new_values |
|
| 700 | + * @return int | boolean $entry_id |
|
| 701 | + */ |
|
| 702 | 702 | private static function insert_entry_into_database( $new_values ) { |
| 703 | 703 | global $wpdb; |
| 704 | 704 | |
@@ -714,11 +714,11 @@ discard block |
||
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | - * Add the new entry to global $frm_vars |
|
| 718 | - * |
|
| 719 | - * @since 2.0.16 |
|
| 720 | - * @param int $entry_id |
|
| 721 | - */ |
|
| 717 | + * Add the new entry to global $frm_vars |
|
| 718 | + * |
|
| 719 | + * @since 2.0.16 |
|
| 720 | + * @param int $entry_id |
|
| 721 | + */ |
|
| 722 | 722 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
| 723 | 723 | global $frm_vars; |
| 724 | 724 | |
@@ -730,12 +730,12 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
| 733 | - * Add entry metas, if there are any |
|
| 734 | - * |
|
| 735 | - * @since 2.0.16 |
|
| 736 | - * @param array $values |
|
| 737 | - * @param int $entry_id |
|
| 738 | - */ |
|
| 733 | + * Add entry metas, if there are any |
|
| 734 | + * |
|
| 735 | + * @since 2.0.16 |
|
| 736 | + * @param array $values |
|
| 737 | + * @param int $entry_id |
|
| 738 | + */ |
|
| 739 | 739 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
| 740 | 740 | if ( isset( $values['item_meta'] ) ) { |
| 741 | 741 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
@@ -743,12 +743,12 @@ discard block |
||
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | /** |
| 746 | - * Trigger frm_after_create_entry hooks |
|
| 747 | - * |
|
| 748 | - * @since 2.0.16 |
|
| 749 | - * @param int $entry_id |
|
| 750 | - * @param array $new_values |
|
| 751 | - */ |
|
| 746 | + * Trigger frm_after_create_entry hooks |
|
| 747 | + * |
|
| 748 | + * @since 2.0.16 |
|
| 749 | + * @param int $entry_id |
|
| 750 | + * @param array $new_values |
|
| 751 | + */ |
|
| 752 | 752 | private static function after_entry_created_actions( $entry_id, $values, $new_values ) { |
| 753 | 753 | // this is a child entry |
| 754 | 754 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
@@ -758,13 +758,13 @@ discard block |
||
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
| 761 | - * Actions to perform immediately after an entry is inserted in the frm_items database |
|
| 762 | - * |
|
| 763 | - * @since 2.0.16 |
|
| 764 | - * @param array $values |
|
| 765 | - * @param array $new_values |
|
| 766 | - * @param int $entry_id |
|
| 767 | - */ |
|
| 761 | + * Actions to perform immediately after an entry is inserted in the frm_items database |
|
| 762 | + * |
|
| 763 | + * @since 2.0.16 |
|
| 764 | + * @param array $values |
|
| 765 | + * @param array $new_values |
|
| 766 | + * @param int $entry_id |
|
| 767 | + */ |
|
| 768 | 768 | private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) { |
| 769 | 769 | |
| 770 | 770 | self::add_new_entry_to_frm_vars( $entry_id ); |
@@ -777,14 +777,14 @@ discard block |
||
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | /** |
| 780 | - * Perform some actions right before updating an entry |
|
| 781 | - * |
|
| 782 | - * @since 2.0.16 |
|
| 783 | - * @param int $id |
|
| 784 | - * @param array $values |
|
| 785 | - * @param string $update_type |
|
| 786 | - * @return boolean $update |
|
| 787 | - */ |
|
| 780 | + * Perform some actions right before updating an entry |
|
| 781 | + * |
|
| 782 | + * @since 2.0.16 |
|
| 783 | + * @param int $id |
|
| 784 | + * @param array $values |
|
| 785 | + * @param string $update_type |
|
| 786 | + * @return boolean $update |
|
| 787 | + */ |
|
| 788 | 788 | private static function before_update_entry( $id, &$values, $update_type ) { |
| 789 | 789 | $update = true; |
| 790 | 790 | |
@@ -802,13 +802,13 @@ discard block |
||
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | /** |
| 805 | - * Package the entry data for updating |
|
| 806 | - * |
|
| 807 | - * @since 2.0.16 |
|
| 808 | - * @param int $id |
|
| 809 | - * @param array $values |
|
| 810 | - * @return array $new_values |
|
| 811 | - */ |
|
| 805 | + * Package the entry data for updating |
|
| 806 | + * |
|
| 807 | + * @since 2.0.16 |
|
| 808 | + * @param int $id |
|
| 809 | + * @param array $values |
|
| 810 | + * @return array $new_values |
|
| 811 | + */ |
|
| 812 | 812 | private static function package_entry_to_update( $id, $values ) { |
| 813 | 813 | global $wpdb; |
| 814 | 814 | |
@@ -842,14 +842,14 @@ discard block |
||
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | /** |
| 845 | - * Perform some actions right after updating an entry |
|
| 846 | - * |
|
| 847 | - * @since 2.0.16 |
|
| 848 | - * @param boolean|int $query_results |
|
| 849 | - * @param int $id |
|
| 850 | - * @param array $values |
|
| 851 | - * @param array $new_values |
|
| 852 | - */ |
|
| 845 | + * Perform some actions right after updating an entry |
|
| 846 | + * |
|
| 847 | + * @since 2.0.16 |
|
| 848 | + * @param boolean|int $query_results |
|
| 849 | + * @param int $id |
|
| 850 | + * @param array $values |
|
| 851 | + * @param array $new_values |
|
| 852 | + */ |
|
| 853 | 853 | private static function after_update_entry( $query_results, $id, $values, $new_values ) { |
| 854 | 854 | if ( $query_results ) { |
| 855 | 855 | self::clear_cache(); |
@@ -871,13 +871,13 @@ discard block |
||
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | /** |
| 874 | - * Create entry from an XML import |
|
| 875 | - * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
| 876 | - * |
|
| 877 | - * @since 2.0.16 |
|
| 878 | - * @param array $values |
|
| 879 | - * @return int | boolean $entry_id |
|
| 880 | - */ |
|
| 874 | + * Create entry from an XML import |
|
| 875 | + * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
| 876 | + * |
|
| 877 | + * @since 2.0.16 |
|
| 878 | + * @param array $values |
|
| 879 | + * @return int | boolean $entry_id |
|
| 880 | + */ |
|
| 881 | 881 | public static function create_entry_from_xml( $values ) { |
| 882 | 882 | $entry_id = self::create_entry( $values, 'xml' ); |
| 883 | 883 | |
@@ -885,26 +885,26 @@ discard block |
||
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | /** |
| 888 | - * Update entry from an XML import |
|
| 889 | - * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
| 890 | - * |
|
| 891 | - * @since 2.0.16 |
|
| 892 | - * @param int $id |
|
| 893 | - * @param array $values |
|
| 894 | - * @return int | boolean $updated |
|
| 895 | - */ |
|
| 888 | + * Update entry from an XML import |
|
| 889 | + * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
| 890 | + * |
|
| 891 | + * @since 2.0.16 |
|
| 892 | + * @param int $id |
|
| 893 | + * @param array $values |
|
| 894 | + * @return int | boolean $updated |
|
| 895 | + */ |
|
| 896 | 896 | public static function update_entry_from_xml( $id, $values ) { |
| 897 | 897 | $updated = self::update_entry( $id, $values, 'xml' ); |
| 898 | 898 | |
| 899 | 899 | return $updated; |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | - /** |
|
| 903 | - * @param string $key |
|
| 904 | - * @return int entry_id |
|
| 905 | - */ |
|
| 902 | + /** |
|
| 903 | + * @param string $key |
|
| 904 | + * @return int entry_id |
|
| 905 | + */ |
|
| 906 | 906 | public static function get_id_by_key( $key ) { |
| 907 | - $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
| 908 | - return $entry_id; |
|
| 909 | - } |
|
| 907 | + $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
| 908 | + return $entry_id; |
|
| 909 | + } |
|
| 910 | 910 | } |