| @@ -3,27 +3,11 @@ | ||
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmMigrate { |
| 7 | - | |
| 8 | - /** | |
| 9 | - * @var string | |
| 10 | - */ | |
| 11 | 7 | public $fields; |
| 12 | - | |
| 13 | - /** | |
| 14 | - * @var string | |
| 15 | - */ | |
| 16 | 8 | public $forms; |
| 17 | - | |
| 18 | - /** | |
| 19 | - * @var string | |
| 20 | - */ | |
| 21 | 9 | public $entries; |
| 22 | - | |
| 23 | - /** | |
| 24 | - * @var string | |
| 25 | - */ | |
| 26 | 10 | public $entry_metas; |
| 27 | 11 | |
| 28 | 12 | public function __construct() { |
| 29 | 13 | global $wpdb; |
| @@ -32,11 +16,8 @@ | ||
| 32 | 16 | $this->entries = $wpdb->prefix . 'frm_items'; |
| 33 | 17 | $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
| 34 | 18 | } |
| 35 | 19 | |
| 36 | - /** | |
| 37 | - * @return void | |
| 38 | - */ | |
| 39 | 20 | public function upgrade() { |
| 40 | 21 | do_action( 'frm_before_install' ); |
| 41 | 22 | |
| 42 | 23 | global $wpdb, $frm_vars; |
| @@ -51,10 +32,8 @@ | ||
| 51 | 32 | ) |
| 52 | 33 | ); |
| 53 | 34 | |
| 54 | 35 | if ( $needs_upgrade ) { |
| 55 | - $this->maybe_delete_htaccess_file(); | |
| 56 | - | |
| 57 | 36 | // update rewrite rules for views and other custom post types |
| 58 | 37 | flush_rewrite_rules(); |
| 59 | 38 | |
| 60 | 39 | require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| @@ -92,42 +71,16 @@ | ||
| 92 | 71 | } |
| 93 | 72 | } |
| 94 | 73 | |
| 95 | 74 | /** |
| 96 | - * Check if the .htaccess file should be deleted based on server response. | |
| 97 | - * If a server has AllowOverride FileInfo but not AllowOverride AuthConfig, JS and CSS files | |
| 98 | - * will result in a 500 error. | |
| 99 | - * | |
| 100 | - * @since 6.27 | |
| 101 | - * | |
| 102 | - * @return void | |
| 103 | - */ | |
| 104 | - private function maybe_delete_htaccess_file() { | |
| 105 | - $css_file_request = wp_remote_get( FrmAppHelper::plugin_url() . '/css/frm_fonts.css' ); | |
| 106 | - | |
| 107 | - if ( 200 === wp_remote_retrieve_response_code( $css_file_request ) ) { | |
| 108 | - return; | |
| 109 | - } | |
| 110 | - | |
| 111 | - $htaccess_path = FrmAppHelper::plugin_path() . '/.htaccess'; | |
| 112 | - | |
| 113 | - if ( file_exists( $htaccess_path ) ) { | |
| 114 | - wp_delete_file( $htaccess_path ); | |
| 115 | - } | |
| 116 | - } | |
| 117 | - | |
| 118 | - /** | |
| 119 | 75 | * Updates some settings for new installs. |
| 120 | 76 | * |
| 121 | 77 | * @since 6.23 |
| 122 | - * | |
| 123 | - * @return void | |
| 124 | 78 | */ |
| 125 | 79 | private function update_settings_for_new_install() { |
| 126 | 80 | $settings = FrmAppHelper::get_settings(); |
| 127 | 81 | |
| 128 | - $settings->denylist_check = 1; | |
| 129 | - $settings->installed_after_welcome_tour_update = 1; | |
| 82 | + $settings->denylist_check = 1; | |
| 130 | 83 | $settings->store(); |
| 131 | 84 | } |
| 132 | 85 | |
| 133 | 86 | /** |
| @@ -151,9 +104,9 @@ | ||
| 151 | 104 | |
| 152 | 105 | $message = array( |
| 153 | 106 | 'key' => 'failed-to-create-tables', |
| 154 | 107 | 'subject' => 'Something went wrong setting up the database', |
| 155 | - 'message' => 'For steps to continue, see our <a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">documentation</a>. If you need assistance, we recommend that you reach out to your hosting provider. Then <a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_add_tables=1' ) ) . '">click here</a> to try again.', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 108 | + 'message' => 'For steps to continue, see our <a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">documentation</a>. If you need assistance, we recommend that you reach out to your hosting provider. Then <a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_add_tables=1' ) ) . '">click here</a> to try again.', | |
| 156 | 109 | 'cta' => '<a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">Learn More</a>', |
| 157 | 110 | 'type' => 'error', |
| 158 | 111 | ); |
| 159 | 112 | |
| @@ -165,14 +118,15 @@ | ||
| 165 | 118 | * @return string |
| 166 | 119 | */ |
| 167 | 120 | public function collation() { |
| 168 | 121 | global $wpdb; |
| 169 | - return $wpdb->has_cap( 'collation' ) ? $wpdb->get_charset_collate() : ''; | |
| 122 | + if ( ! $wpdb->has_cap( 'collation' ) ) { | |
| 123 | + return ''; | |
| 124 | + } | |
| 125 | + | |
| 126 | + return $wpdb->get_charset_collate(); | |
| 170 | 127 | } |
| 171 | 128 | |
| 172 | - /** | |
| 173 | - * @return void | |
| 174 | - */ | |
| 175 | 129 | private function create_tables() { |
| 176 | 130 | $charset_collate = $this->collation(); |
| 177 | 131 | $sql = array(); |
| 178 | 132 | |
| @@ -308,9 +262,8 @@ | ||
| 308 | 262 | * @since 6.6 |
| 309 | 263 | * |
| 310 | 264 | * @param string $table_name |
| 311 | 265 | * @param string $index_name |
| 312 | - * | |
| 313 | 266 | * @return bool |
| 314 | 267 | */ |
| 315 | 268 | private static function index_exists( $table_name, $index_name ) { |
| 316 | 269 | global $wpdb; |
| @@ -326,14 +279,10 @@ | ||
| 326 | 279 | ); |
| 327 | 280 | return (bool) $row; |
| 328 | 281 | } |
| 329 | 282 | |
| 330 | - /** | |
| 331 | - * @return void | |
| 332 | - */ | |
| 333 | 283 | private function maybe_create_contact_form() { |
| 334 | 284 | $form_exists = FrmForm::get_id_by_key( 'contact-form' ); |
| 335 | - | |
| 336 | 285 | if ( ! $form_exists ) { |
| 337 | 286 | $this->add_default_template(); |
| 338 | 287 | } |
| 339 | 288 | } |
| @@ -341,10 +290,8 @@ | ||
| 341 | 290 | /** |
| 342 | 291 | * Create the default contact form |
| 343 | 292 | * |
| 344 | 293 | * @since 3.06 |
| 345 | - * | |
| 346 | - * @return void | |
| 347 | 294 | */ |
| 348 | 295 | private function add_default_template() { |
| 349 | 296 | if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) { |
| 350 | 297 | // XML import is not enabled on your server. |
| @@ -352,9 +299,10 @@ | ||
| 352 | 299 | } |
| 353 | 300 | |
| 354 | 301 | $set_err = libxml_use_internal_errors( true ); |
| 355 | 302 | $loader = FrmXMLHelper::maybe_libxml_disable_entity_loader( true ); |
| 356 | - $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml'; | |
| 303 | + | |
| 304 | + $file = FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml'; | |
| 357 | 305 | FrmXMLHelper::import_xml( $file ); |
| 358 | 306 | |
| 359 | 307 | libxml_use_internal_errors( $set_err ); |
| 360 | 308 | FrmXMLHelper::maybe_libxml_disable_entity_loader( $loader ); |
| @@ -361,17 +309,14 @@ | ||
| 361 | 309 | } |
| 362 | 310 | |
| 363 | 311 | /** |
| 364 | 312 | * @param int|string $old_db_version |
| 365 | - * | |
| 366 | - * @return void | |
| 367 | 313 | */ |
| 368 | 314 | private function migrate_data( $old_db_version ) { |
| 369 | 315 | if ( ! $old_db_version ) { |
| 370 | 316 | $old_db_version = get_option( 'frm_db_version' ); |
| 371 | 317 | } |
| 372 | - | |
| 373 | - if ( str_contains( $old_db_version, '-' ) ) { | |
| 318 | + if ( strpos( $old_db_version, '-' ) ) { | |
| 374 | 319 | $last_upgrade = explode( '-', $old_db_version ); |
| 375 | 320 | $old_db_version = (int) $last_upgrade[1]; |
| 376 | 321 | } |
| 377 | 322 | |
| @@ -379,10 +324,9 @@ | ||
| 379 | 324 | // bail if we don't know the previous version |
| 380 | 325 | return; |
| 381 | 326 | } |
| 382 | 327 | |
| 383 | - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 ); | |
| 384 | - | |
| 328 | + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101 ); | |
| 385 | 329 | foreach ( $migrations as $migration ) { |
| 386 | 330 | if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) { |
| 387 | 331 | $function_name = 'migrate_to_' . $migration; |
| 388 | 332 | $this->$function_name(); |
| @@ -415,9 +359,8 @@ | ||
| 415 | 359 | |
| 416 | 360 | // Delete roles. |
| 417 | 361 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| 418 | 362 | $roles = get_editable_roles(); |
| 419 | - | |
| 420 | 363 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 421 | 364 | foreach ( $roles as $role => $details ) { |
| 422 | 365 | $wp_roles->remove_cap( $role, $frm_role ); |
| 423 | 366 | unset( $role, $details ); |
| @@ -431,10 +374,9 @@ | ||
| 431 | 374 | // prevent the post deletion from triggering entries to be deleted |
| 432 | 375 | remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' ); |
| 433 | 376 | remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' ); |
| 434 | 377 | |
| 435 | - $post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 436 | - | |
| 378 | + $post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) ); | |
| 437 | 379 | foreach ( $post_ids as $post_id ) { |
| 438 | 380 | // Delete's each post. |
| 439 | 381 | wp_delete_post( $post_id, true ); |
| 440 | 382 | } |
| @@ -445,9 +387,9 @@ | ||
| 445 | 387 | delete_transient( 'frm_options' ); |
| 446 | 388 | delete_transient( 'frmpro_options' ); |
| 447 | 389 | delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME ); |
| 448 | 390 | |
| 449 | - $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 391 | + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); | |
| 450 | 392 | |
| 451 | 393 | do_action( 'frm_after_uninstall' ); |
| 452 | 394 | |
| 453 | 395 | return true; |
| @@ -453,31 +395,11 @@ | ||
| 453 | 395 | return true; |
| 454 | 396 | } |
| 455 | 397 | |
| 456 | 398 | /** |
| 457 | - * In older versions of Lite, it's possible we've saved the wrong location ID. | |
| 458 | - * So force it to get valid values again. | |
| 459 | - * | |
| 460 | - * @since 6.25 | |
| 461 | - * | |
| 462 | - * @return void | |
| 463 | - */ | |
| 464 | - private function migrate_to_104() { | |
| 465 | - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'test' ) ) { | |
| 466 | - FrmSquareLiteConnectHelper::get_location_id( true, 'test' ); | |
| 467 | - } | |
| 468 | - | |
| 469 | - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) { | |
| 470 | - FrmSquareLiteConnectHelper::get_location_id( true, 'live' ); | |
| 471 | - } | |
| 472 | - } | |
| 473 | - | |
| 474 | - /** | |
| 475 | 399 | * Disables summary email for multisite (not the main site) if recipient setting isn't changed. |
| 476 | 400 | * |
| 477 | 401 | * @since 6.8 |
| 478 | - * | |
| 479 | - * @return void | |
| 480 | 402 | */ |
| 481 | 403 | private function migrate_to_101() { |
| 482 | 404 | if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) { |
| 483 | 405 | return; |
| @@ -483,9 +405,8 @@ | ||
| 483 | 405 | return; |
| 484 | 406 | } |
| 485 | 407 | |
| 486 | 408 | $frm_settings = FrmAppHelper::get_settings(); |
| 487 | - | |
| 488 | 409 | if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) { |
| 489 | 410 | // User changed it. |
| 490 | 411 | return; |
| 491 | 412 | } |
| @@ -497,10 +418,8 @@ | ||
| 497 | 418 | /** |
| 498 | 419 | * Clear frmpro_css transient. |
| 499 | 420 | * |
| 500 | 421 | * @since 4.10.02 |
| 501 | - * | |
| 502 | - * @return void | |
| 503 | 422 | */ |
| 504 | 423 | private function migrate_to_98() { |
| 505 | 424 | delete_transient( 'frmpro_css' ); |
| 506 | 425 | } |
| @@ -508,10 +427,8 @@ | ||
| 508 | 427 | /** |
| 509 | 428 | * Move default_blank and clear_on_focus to placeholder. |
| 510 | 429 | * |
| 511 | 430 | * @since 4.0 |
| 512 | - * | |
| 513 | - * @return void | |
| 514 | 431 | */ |
| 515 | 432 | private function migrate_to_97() { |
| 516 | 433 | $this->migrate_to_placeholder( 'clear_on_focus' ); |
| 517 | 434 | $this->migrate_to_placeholder( 'default_blank' ); |
| @@ -520,12 +437,8 @@ | ||
| 520 | 437 | /** |
| 521 | 438 | * Move clear_on_focus or default_blank to placeholder. |
| 522 | 439 | * |
| 523 | 440 | * @since 4.0 |
| 524 | - * | |
| 525 | - * @param string $type Field option key to migrate. | |
| 526 | - * | |
| 527 | - * @return void | |
| 528 | 441 | */ |
| 529 | 442 | private function migrate_to_placeholder( $type = 'clear_on_focus' ) { |
| 530 | 443 | $query = array( |
| 531 | 444 | 'field_options like' => '"' . $type . '";s:1:"1";', |
| @@ -536,10 +449,9 @@ | ||
| 536 | 449 | foreach ( $fields as $field ) { |
| 537 | 450 | FrmAppHelper::unserialize_or_decode( $field->field_options ); |
| 538 | 451 | FrmAppHelper::unserialize_or_decode( $field->options ); |
| 539 | 452 | $update_values = FrmXMLHelper::migrate_field_placeholder( $field, $type ); |
| 540 | - | |
| 541 | - if ( ! $update_values ) { | |
| 453 | + if ( empty( $update_values ) ) { | |
| 542 | 454 | continue; |
| 543 | 455 | } |
| 544 | 456 | |
| 545 | 457 | FrmField::update( $field->id, $update_values ); |
| @@ -550,15 +462,11 @@ | ||
| 550 | 462 | /** |
| 551 | 463 | * Delete unneeded default templates |
| 552 | 464 | * |
| 553 | 465 | * @since 3.06 |
| 554 | - * | |
| 555 | - * @return void | |
| 556 | 466 | */ |
| 557 | 467 | private function migrate_to_90() { |
| 558 | 468 | $form = FrmForm::getOne( 'contact' ); |
| 559 | - | |
| 560 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 561 | 469 | if ( $form && $form->default_template == 1 ) { |
| 562 | 470 | FrmForm::destroy( 'contact' ); |
| 563 | 471 | } |
| 564 | 472 | } |
| @@ -566,15 +474,14 @@ | ||
| 566 | 474 | /** |
| 567 | 475 | * Reverse migration 17 -- Divide by 9 |
| 568 | 476 | * |
| 569 | 477 | * @since 3.0.05 |
| 570 | - * | |
| 571 | - * @return void | |
| 572 | 478 | */ |
| 573 | 479 | private function migrate_to_86() { |
| 480 | + | |
| 574 | 481 | $fields = $this->get_fields_with_size(); |
| 575 | 482 | |
| 576 | - foreach ( $fields as $f ) { | |
| 483 | + foreach ( (array) $fields as $f ) { | |
| 577 | 484 | FrmAppHelper::unserialize_or_decode( $f->field_options ); |
| 578 | 485 | $size = $f->field_options['size']; |
| 579 | 486 | $this->maybe_convert_migrated_size( $size ); |
| 580 | 487 | |
| @@ -588,10 +495,9 @@ | ||
| 588 | 495 | } |
| 589 | 496 | |
| 590 | 497 | // reverse the extra size changes in widgets |
| 591 | 498 | $widgets = get_option( 'widget_frm_show_form' ); |
| 592 | - | |
| 593 | - if ( ! $widgets ) { | |
| 499 | + if ( empty( $widgets ) ) { | |
| 594 | 500 | return; |
| 595 | 501 | } |
| 596 | 502 | |
| 597 | 503 | $this->revert_widget_field_size(); |
| @@ -596,11 +502,8 @@ | ||
| 596 | 502 | |
| 597 | 503 | $this->revert_widget_field_size(); |
| 598 | 504 | } |
| 599 | 505 | |
| 600 | - /** | |
| 601 | - * @return array | |
| 602 | - */ | |
| 603 | 506 | private function get_fields_with_size() { |
| 604 | 507 | $field_types = array( |
| 605 | 508 | 'textarea', |
| 606 | 509 | 'text', |
| @@ -628,20 +531,16 @@ | ||
| 628 | 531 | /** |
| 629 | 532 | * Reverse the extra size changes in widgets |
| 630 | 533 | * |
| 631 | 534 | * @since 3.0.05 |
| 632 | - * | |
| 633 | - * @return void | |
| 634 | 535 | */ |
| 635 | 536 | private function revert_widget_field_size() { |
| 636 | 537 | $widgets = get_option( 'widget_frm_show_form' ); |
| 637 | - | |
| 638 | - if ( ! $widgets ) { | |
| 538 | + if ( empty( $widgets ) ) { | |
| 639 | 539 | return; |
| 640 | 540 | } |
| 641 | 541 | |
| 642 | 542 | FrmAppHelper::unserialize_or_decode( $widgets ); |
| 643 | - | |
| 644 | 543 | foreach ( $widgets as $k => $widget ) { |
| 645 | 544 | if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
| 646 | 545 | continue; |
| 647 | 546 | } |
| @@ -647,9 +546,8 @@ | ||
| 647 | 546 | } |
| 648 | 547 | |
| 649 | 548 | $this->maybe_convert_migrated_size( $widgets[ $k ]['size'] ); |
| 650 | 549 | } |
| 651 | - | |
| 652 | 550 | update_option( 'widget_frm_show_form', $widgets ); |
| 653 | 551 | } |
| 654 | 552 | |
| 655 | 553 | /** |
| @@ -655,28 +553,23 @@ | ||
| 655 | 553 | /** |
| 656 | 554 | * Divide by 9 to reverse the multiplication |
| 657 | 555 | * |
| 658 | 556 | * @since 3.0.05 |
| 659 | - * | |
| 660 | - * @param string $size Size string to maybe convert, passed by reference. | |
| 661 | - * | |
| 662 | - * @return void | |
| 663 | 557 | */ |
| 664 | 558 | private function maybe_convert_migrated_size( &$size ) { |
| 665 | - $has_px_size = ! empty( $size ) && str_contains( $size, 'px' ); | |
| 666 | - | |
| 559 | + $has_px_size = ! empty( $size ) && strpos( $size, 'px' ); | |
| 667 | 560 | if ( ! $has_px_size ) { |
| 668 | 561 | return; |
| 669 | 562 | } |
| 670 | 563 | |
| 671 | 564 | $int_size = str_replace( 'px', '', $size ); |
| 672 | - | |
| 673 | 565 | if ( ! is_numeric( $int_size ) || (int) $int_size < 900 ) { |
| 674 | 566 | return; |
| 675 | 567 | } |
| 676 | 568 | |
| 677 | 569 | $pixel_conversion = 9; |
| 678 | - $size = round( (int) $int_size / $pixel_conversion ); | |
| 570 | + | |
| 571 | + $size = round( (int) $int_size / $pixel_conversion ); | |
| 679 | 572 | } |
| 680 | 573 | |
| 681 | 574 | /** |
| 682 | 575 | * Migrate old styling settings. If sites are using the old |
| @@ -682,17 +575,14 @@ | ||
| 682 | 575 | * Migrate old styling settings. If sites are using the old |
| 683 | 576 | * default 400px field width, switch it to 100% |
| 684 | 577 | * |
| 685 | 578 | * @since 2.0.4 |
| 686 | - * | |
| 687 | - * @return void | |
| 688 | 579 | */ |
| 689 | 580 | private function migrate_to_25() { |
| 690 | 581 | // get the style that was created with the style migration |
| 691 | 582 | $frm_style = new FrmStyle(); |
| 692 | 583 | $styles = $frm_style->get_all( 'post_date', 'ASC', 1 ); |
| 693 | - | |
| 694 | - if ( ! $styles ) { | |
| 584 | + if ( empty( $styles ) ) { | |
| 695 | 585 | return; |
| 696 | 586 | } |
| 697 | 587 | |
| 698 | 588 | foreach ( $styles as $style ) { |
| @@ -709,16 +599,13 @@ | ||
| 709 | 599 | * Check if the parent_form_id columns exists. |
| 710 | 600 | * If not, try and add it again |
| 711 | 601 | * |
| 712 | 602 | * @since 2.0.2 |
| 713 | - * | |
| 714 | - * @return void | |
| 715 | 603 | */ |
| 716 | 604 | private function migrate_to_23() { |
| 717 | 605 | global $wpdb; |
| 718 | 606 | $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 719 | - | |
| 720 | - if ( ! $exists ) { | |
| 607 | + if ( empty( $exists ) ) { | |
| 721 | 608 | $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 722 | 609 | } |
| 723 | 610 | } |
| 724 | 611 | |
| @@ -723,10 +610,8 @@ | ||
| 723 | 610 | } |
| 724 | 611 | |
| 725 | 612 | /** |
| 726 | 613 | * Change field size from character to pixel -- Multiply by 9 |
| 727 | - * | |
| 728 | - * @return void | |
| 729 | 614 | */ |
| 730 | 615 | private function migrate_to_17() { |
| 731 | 616 | $fields = $this->get_fields_with_size(); |
| 732 | 617 | |
| @@ -731,9 +616,8 @@ | ||
| 731 | 616 | $fields = $this->get_fields_with_size(); |
| 732 | 617 | |
| 733 | 618 | foreach ( $fields as $f ) { |
| 734 | 619 | FrmAppHelper::unserialize_or_decode( $f->field_options ); |
| 735 | - | |
| 736 | 620 | if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
| 737 | 621 | continue; |
| 738 | 622 | } |
| 739 | 623 | |
| @@ -747,20 +631,16 @@ | ||
| 747 | 631 | } |
| 748 | 632 | |
| 749 | 633 | /** |
| 750 | 634 | * Change the characters in widgets to pixels |
| 751 | - * | |
| 752 | - * @return void | |
| 753 | 635 | */ |
| 754 | 636 | private function adjust_widget_size() { |
| 755 | 637 | $widgets = get_option( 'widget_frm_show_form' ); |
| 756 | - | |
| 757 | - if ( ! $widgets ) { | |
| 638 | + if ( empty( $widgets ) ) { | |
| 758 | 639 | return; |
| 759 | 640 | } |
| 760 | 641 | |
| 761 | 642 | FrmAppHelper::unserialize_or_decode( $widgets ); |
| 762 | - | |
| 763 | 643 | foreach ( $widgets as $k => $widget ) { |
| 764 | 644 | if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
| 765 | 645 | continue; |
| 766 | 646 | } |
| @@ -765,17 +645,11 @@ | ||
| 765 | 645 | continue; |
| 766 | 646 | } |
| 767 | 647 | $this->convert_character_to_px( $widgets[ $k ]['size'] ); |
| 768 | 648 | } |
| 769 | - | |
| 770 | 649 | update_option( 'widget_frm_show_form', $widgets ); |
| 771 | 650 | } |
| 772 | 651 | |
| 773 | - /** | |
| 774 | - * @param string $size | |
| 775 | - * | |
| 776 | - * @return void | |
| 777 | - */ | |
| 778 | 652 | private function convert_character_to_px( &$size ) { |
| 779 | 653 | $pixel_conversion = 9; |
| 780 | 654 | |
| 781 | 655 | $size = round( $pixel_conversion * (int) $size ); |
| @@ -834,9 +708,10 @@ | ||
| 834 | 708 | |
| 835 | 709 | private function migrate_to_11() { |
| 836 | 710 | global $wpdb; |
| 837 | 711 | |
| 838 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); | |
| 712 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); | |
| 713 | + | |
| 839 | 714 | $sending = __( 'Sending', 'formidable' ); |
| 840 | 715 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
| 841 | 716 | $old_default_html = <<<DEFAULT_HTML |
| 842 | 717 | <div class="frm_submit"> |
| @@ -848,21 +723,18 @@ | ||
| 848 | 723 | unset( $sending, $img ); |
| 849 | 724 | |
| 850 | 725 | $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
| 851 | 726 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 852 | - | |
| 853 | 727 | foreach ( $forms as $form ) { |
| 854 | 728 | FrmAppHelper::unserialize_or_decode( $form->options ); |
| 855 | - | |
| 856 | 729 | if ( empty( $form->options['submit_html'] ) ) { |
| 857 | 730 | continue; |
| 858 | 731 | } |
| 859 | 732 | |
| 860 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 861 | 733 | if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
| 862 | 734 | $form->options['submit_html'] = $new_default_html; |
| 863 | 735 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 864 | - } elseif ( ! str_contains( $form->options['submit_html'], 'save_draft' ) ) { | |
| 736 | + } elseif ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) { | |
| 865 | 737 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 866 | 738 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 867 | 739 | } |
| 868 | 740 | unset( $form ); |