| @@ -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; |
| @@ -54,29 +35,22 @@ | ||
| 54 | 35 | if ( $needs_upgrade ) { |
| 55 | 36 | // update rewrite rules for views and other custom post types |
| 56 | 37 | flush_rewrite_rules(); |
| 57 | 38 | |
| 58 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 39 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
| 59 | 40 | |
| 60 | 41 | $old_db_version = get_option( 'frm_db_version' ); |
| 61 | 42 | |
| 62 | 43 | $this->create_tables(); |
| 63 | 44 | $this->migrate_data( $old_db_version ); |
| 64 | - $this->check_that_tables_exist(); | |
| 65 | 45 | |
| 66 | - // SAVE DB VERSION. | |
| 46 | + /***** SAVE DB VERSION *****/ | |
| 67 | 47 | update_option( 'frm_db_version', FrmAppHelper::plugin_version() . '-' . FrmAppHelper::$db_version ); |
| 68 | 48 | |
| 69 | 49 | if ( ! $old_db_version ) { |
| 70 | 50 | $this->maybe_create_contact_form(); |
| 71 | - | |
| 72 | - if ( false === get_option( 'frm_first_activation' ) ) { | |
| 73 | - update_option( 'frm_first_activation', time(), false ); | |
| 74 | - } | |
| 75 | - | |
| 76 | - $this->update_settings_for_new_install(); | |
| 77 | 51 | } |
| 78 | - }//end if | |
| 52 | + } | |
| 79 | 53 | |
| 80 | 54 | do_action( 'frm_after_install' ); |
| 81 | 55 | |
| 82 | 56 | $frm_vars['doing_upgrade'] = false; |
| @@ -89,60 +63,10 @@ | ||
| 89 | 63 | $frm_style->update( 'default' ); |
| 90 | 64 | } |
| 91 | 65 | } |
| 92 | 66 | |
| 93 | - /** | |
| 94 | - * Updates some settings for new installs. | |
| 95 | - * | |
| 96 | - * @since 6.23 | |
| 97 | - * | |
| 98 | - * @return void | |
| 99 | - */ | |
| 100 | - private function update_settings_for_new_install() { | |
| 101 | - $settings = FrmAppHelper::get_settings(); | |
| 102 | - | |
| 103 | - $settings->denylist_check = 1; | |
| 104 | - $settings->installed_after_welcome_tour_update = 1; | |
| 105 | - $settings->store(); | |
| 106 | - } | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * If we fail to create the database tables, add an inbox notice. | |
| 110 | - * This informs the user that they need to correct the issue and try again. | |
| 111 | - * | |
| 112 | - * @since 6.19 | |
| 113 | - * | |
| 114 | - * @return void | |
| 115 | - */ | |
| 116 | - private function check_that_tables_exist() { | |
| 117 | - // Check the DB that the table $this->forms exists. | |
| 118 | - global $wpdb; | |
| 119 | - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $this->forms ) ); | |
| 120 | - | |
| 121 | - if ( $exists ) { | |
| 122 | - $inbox = new FrmInbox(); | |
| 123 | - $inbox->dismiss( 'failed-to-create-tables' ); | |
| 124 | - return; | |
| 125 | - } | |
| 126 | - | |
| 127 | - $message = array( | |
| 128 | - 'key' => 'failed-to-create-tables', | |
| 129 | - 'subject' => 'Something went wrong setting up the database', | |
| 130 | - '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.', | |
| 131 | - 'cta' => '<a href="https://formidableforms.com/knowledgebase/install-formidable-forms/#kb-missing-database-tables">Learn More</a>', | |
| 132 | - 'type' => 'error', | |
| 133 | - ); | |
| 134 | - | |
| 135 | - $inbox = new FrmInbox(); | |
| 136 | - $inbox->add_message( $message ); | |
| 137 | - } | |
| 138 | - | |
| 139 | - /** | |
| 140 | - * @return string | |
| 141 | - */ | |
| 142 | 67 | public function collation() { |
| 143 | 68 | global $wpdb; |
| 144 | - | |
| 145 | 69 | if ( ! $wpdb->has_cap( 'collation' ) ) { |
| 146 | 70 | return ''; |
| 147 | 71 | } |
| 148 | 72 | |
| @@ -148,11 +72,8 @@ | ||
| 148 | 72 | |
| 149 | 73 | return $wpdb->get_charset_collate(); |
| 150 | 74 | } |
| 151 | 75 | |
| 152 | - /** | |
| 153 | - * @return void | |
| 154 | - */ | |
| 155 | 76 | private function create_tables() { |
| 156 | 77 | $charset_collate = $this->collation(); |
| 157 | 78 | $sql = array(); |
| 158 | 79 | |
| @@ -244,10 +165,8 @@ | ||
| 244 | 165 | /** |
| 245 | 166 | * These indexes help optimize database queries for entries. |
| 246 | 167 | * |
| 247 | 168 | * @since 6.6 |
| 248 | - * @since 6.16.3 idx_form_id_is_draft was also added to frm_items. | |
| 249 | - * @since 6.17 idx_form_id_type was also added to frm_fields. | |
| 250 | 169 | * |
| 251 | 170 | * @return void |
| 252 | 171 | */ |
| 253 | 172 | private function add_composite_indexes_for_entries() { |
| @@ -265,22 +184,8 @@ | ||
| 265 | 184 | |
| 266 | 185 | if ( ! self::index_exists( $table_name, $index_name ) ) { |
| 267 | 186 | $wpdb->query( "CREATE INDEX idx_field_id_item_id ON `{$wpdb->prefix}frm_item_metas` (field_id, item_id)" ); |
| 268 | 187 | } |
| 269 | - | |
| 270 | - $table_name = "{$wpdb->prefix}frm_items"; | |
| 271 | - $index_name = 'idx_form_id_is_draft'; | |
| 272 | - | |
| 273 | - if ( ! self::index_exists( $table_name, $index_name ) ) { | |
| 274 | - $wpdb->query( "CREATE INDEX idx_form_id_is_draft ON `{$wpdb->prefix}frm_items` (form_id, is_draft)" ); | |
| 275 | - } | |
| 276 | - | |
| 277 | - $table_name = "{$wpdb->prefix}frm_fields"; | |
| 278 | - $index_name = 'idx_form_id_type'; | |
| 279 | - | |
| 280 | - if ( ! self::index_exists( $table_name, $index_name ) ) { | |
| 281 | - $wpdb->query( "CREATE INDEX idx_form_id_type ON `{$wpdb->prefix}frm_fields` (form_id, type(30))" ); | |
| 282 | - } | |
| 283 | 188 | } |
| 284 | 189 | |
| 285 | 190 | /** |
| 286 | 191 | * Check that an index exists in a database table before trying to add it (which results in an error). |
| @@ -288,9 +193,8 @@ | ||
| 288 | 193 | * @since 6.6 |
| 289 | 194 | * |
| 290 | 195 | * @param string $table_name |
| 291 | 196 | * @param string $index_name |
| 292 | - * | |
| 293 | 197 | * @return bool |
| 294 | 198 | */ |
| 295 | 199 | private static function index_exists( $table_name, $index_name ) { |
| 296 | 200 | global $wpdb; |
| @@ -306,14 +210,10 @@ | ||
| 306 | 210 | ); |
| 307 | 211 | return (bool) $row; |
| 308 | 212 | } |
| 309 | 213 | |
| 310 | - /** | |
| 311 | - * @return void | |
| 312 | - */ | |
| 313 | 214 | private function maybe_create_contact_form() { |
| 314 | 215 | $form_exists = FrmForm::get_id_by_key( 'contact-form' ); |
| 315 | - | |
| 316 | 216 | if ( ! $form_exists ) { |
| 317 | 217 | $this->add_default_template(); |
| 318 | 218 | } |
| 319 | 219 | } |
| @@ -321,10 +221,8 @@ | ||
| 321 | 221 | /** |
| 322 | 222 | * Create the default contact form |
| 323 | 223 | * |
| 324 | 224 | * @since 3.06 |
| 325 | - * | |
| 326 | - * @return void | |
| 327 | 225 | */ |
| 328 | 226 | private function add_default_template() { |
| 329 | 227 | if ( FrmXMLHelper::check_if_libxml_disable_entity_loader_exists() ) { |
| 330 | 228 | // XML import is not enabled on your server. |
| @@ -342,16 +240,13 @@ | ||
| 342 | 240 | } |
| 343 | 241 | |
| 344 | 242 | /** |
| 345 | 243 | * @param int|string $old_db_version |
| 346 | - * | |
| 347 | - * @return void | |
| 348 | 244 | */ |
| 349 | 245 | private function migrate_data( $old_db_version ) { |
| 350 | 246 | if ( ! $old_db_version ) { |
| 351 | 247 | $old_db_version = get_option( 'frm_db_version' ); |
| 352 | 248 | } |
| 353 | - | |
| 354 | 249 | if ( strpos( $old_db_version, '-' ) ) { |
| 355 | 250 | $last_upgrade = explode( '-', $old_db_version ); |
| 356 | 251 | $old_db_version = (int) $last_upgrade[1]; |
| 357 | 252 | } |
| @@ -360,10 +255,9 @@ | ||
| 360 | 255 | // bail if we don't know the previous version |
| 361 | 256 | return; |
| 362 | 257 | } |
| 363 | 258 | |
| 364 | - $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98, 101, 104 ); | |
| 365 | - | |
| 259 | + $migrations = array( 16, 11, 16, 17, 23, 25, 86, 90, 97, 98 ); | |
| 366 | 260 | foreach ( $migrations as $migration ) { |
| 367 | 261 | if ( FrmAppHelper::$db_version >= $migration && $old_db_version < $migration ) { |
| 368 | 262 | $function_name = 'migrate_to_' . $migration; |
| 369 | 263 | $this->$function_name(); |
| @@ -390,15 +284,14 @@ | ||
| 390 | 284 | delete_option( 'frm_lite_settings_upgrade' ); |
| 391 | 285 | delete_option( 'frm-usage-uuid' ); |
| 392 | 286 | delete_option( 'frm_inbox' ); |
| 393 | 287 | delete_option( 'frmpro_css' ); |
| 394 | - delete_option( FrmOnboardingWizardController::REDIRECT_STATUS_OPTION ); | |
| 288 | + delete_option( 'frm_welcome_redirect' ); | |
| 395 | 289 | delete_option( FrmEmailSummaryHelper::$option_name ); |
| 396 | 290 | |
| 397 | 291 | // Delete roles. |
| 398 | 292 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| 399 | 293 | $roles = get_editable_roles(); |
| 400 | - | |
| 401 | 294 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 402 | 295 | foreach ( $roles as $role => $details ) { |
| 403 | 296 | $wp_roles->remove_cap( $role, $frm_role ); |
| 404 | 297 | unset( $role, $details ); |
| @@ -413,9 +306,8 @@ | ||
| 413 | 306 | remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' ); |
| 414 | 307 | remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' ); |
| 415 | 308 | |
| 416 | 309 | $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' ) ); |
| 417 | - | |
| 418 | 310 | foreach ( $post_ids as $post_id ) { |
| 419 | 311 | // Delete's each post. |
| 420 | 312 | wp_delete_post( $post_id, true ); |
| 421 | 313 | } |
| @@ -424,9 +316,9 @@ | ||
| 424 | 316 | // delete transients |
| 425 | 317 | delete_transient( 'frmpro_css' ); |
| 426 | 318 | delete_transient( 'frm_options' ); |
| 427 | 319 | delete_transient( 'frmpro_options' ); |
| 428 | - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME ); | |
| 320 | + delete_transient( 'frm_activation_redirect' ); | |
| 429 | 321 | |
| 430 | 322 | $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_%' ) ); |
| 431 | 323 | |
| 432 | 324 | do_action( 'frm_after_uninstall' ); |
| @@ -434,54 +326,11 @@ | ||
| 434 | 326 | return true; |
| 435 | 327 | } |
| 436 | 328 | |
| 437 | 329 | /** |
| 438 | - * In older versions of Lite, it's possible we've saved the wrong location ID. | |
| 439 | - * So force it to get valid values again. | |
| 440 | - * | |
| 441 | - * @since 6.25 | |
| 442 | - * | |
| 443 | - * @return void | |
| 444 | - */ | |
| 445 | - private function migrate_to_104() { | |
| 446 | - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'test' ) ) { | |
| 447 | - FrmSquareLiteConnectHelper::get_location_id( true, 'test' ); | |
| 448 | - } | |
| 449 | - | |
| 450 | - if ( FrmSquareLiteConnectHelper::get_merchant_id( 'live' ) ) { | |
| 451 | - FrmSquareLiteConnectHelper::get_location_id( true, 'live' ); | |
| 452 | - } | |
| 453 | - } | |
| 454 | - | |
| 455 | - /** | |
| 456 | - * Disables summary email for multisite (not the main site) if recipient setting isn't changed. | |
| 457 | - * | |
| 458 | - * @since 6.8 | |
| 459 | - * | |
| 460 | - * @return void | |
| 461 | - */ | |
| 462 | - private function migrate_to_101() { | |
| 463 | - if ( ! is_multisite() || get_main_site_id() === get_current_blog_id() ) { | |
| 464 | - return; | |
| 465 | - } | |
| 466 | - | |
| 467 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 468 | - | |
| 469 | - if ( empty( $frm_settings->summary_emails ) || '[admin_email]' !== $frm_settings->summary_emails_recipients ) { | |
| 470 | - // User changed it. | |
| 471 | - return; | |
| 472 | - } | |
| 473 | - | |
| 474 | - $frm_settings->summary_emails = 0; | |
| 475 | - $frm_settings->store(); | |
| 476 | - } | |
| 477 | - | |
| 478 | - /** | |
| 479 | 330 | * Clear frmpro_css transient. |
| 480 | 331 | * |
| 481 | 332 | * @since 4.10.02 |
| 482 | - * | |
| 483 | - * @return void | |
| 484 | 333 | */ |
| 485 | 334 | private function migrate_to_98() { |
| 486 | 335 | delete_transient( 'frmpro_css' ); |
| 487 | 336 | } |
| @@ -489,10 +338,8 @@ | ||
| 489 | 338 | /** |
| 490 | 339 | * Move default_blank and clear_on_focus to placeholder. |
| 491 | 340 | * |
| 492 | 341 | * @since 4.0 |
| 493 | - * | |
| 494 | - * @return void | |
| 495 | 342 | */ |
| 496 | 343 | private function migrate_to_97() { |
| 497 | 344 | $this->migrate_to_placeholder( 'clear_on_focus' ); |
| 498 | 345 | $this->migrate_to_placeholder( 'default_blank' ); |
| @@ -501,12 +348,8 @@ | ||
| 501 | 348 | /** |
| 502 | 349 | * Move clear_on_focus or default_blank to placeholder. |
| 503 | 350 | * |
| 504 | 351 | * @since 4.0 |
| 505 | - * | |
| 506 | - * @param string $type Field option key to migrate. | |
| 507 | - * | |
| 508 | - * @return void | |
| 509 | 352 | */ |
| 510 | 353 | private function migrate_to_placeholder( $type = 'clear_on_focus' ) { |
| 511 | 354 | $query = array( |
| 512 | 355 | 'field_options like' => '"' . $type . '";s:1:"1";', |
| @@ -517,9 +360,8 @@ | ||
| 517 | 360 | foreach ( $fields as $field ) { |
| 518 | 361 | FrmAppHelper::unserialize_or_decode( $field->field_options ); |
| 519 | 362 | FrmAppHelper::unserialize_or_decode( $field->options ); |
| 520 | 363 | $update_values = FrmXMLHelper::migrate_field_placeholder( $field, $type ); |
| 521 | - | |
| 522 | 364 | if ( empty( $update_values ) ) { |
| 523 | 365 | continue; |
| 524 | 366 | } |
| 525 | 367 | |
| @@ -528,17 +370,14 @@ | ||
| 528 | 370 | } |
| 529 | 371 | } |
| 530 | 372 | |
| 531 | 373 | /** |
| 532 | - * Delete unneeded default templates | |
| 374 | + * Delete uneeded default templates | |
| 533 | 375 | * |
| 534 | 376 | * @since 3.06 |
| 535 | - * | |
| 536 | - * @return void | |
| 537 | 377 | */ |
| 538 | 378 | private function migrate_to_90() { |
| 539 | 379 | $form = FrmForm::getOne( 'contact' ); |
| 540 | - | |
| 541 | 380 | if ( $form && $form->default_template == 1 ) { |
| 542 | 381 | FrmForm::destroy( 'contact' ); |
| 543 | 382 | } |
| 544 | 383 | } |
| @@ -546,18 +385,16 @@ | ||
| 546 | 385 | /** |
| 547 | 386 | * Reverse migration 17 -- Divide by 9 |
| 548 | 387 | * |
| 549 | 388 | * @since 3.0.05 |
| 550 | - * | |
| 551 | - * @return void | |
| 552 | 389 | */ |
| 553 | 390 | private function migrate_to_86() { |
| 554 | 391 | |
| 555 | 392 | $fields = $this->get_fields_with_size(); |
| 556 | 393 | |
| 557 | - foreach ( $fields as $f ) { | |
| 394 | + foreach ( (array) $fields as $f ) { | |
| 558 | 395 | FrmAppHelper::unserialize_or_decode( $f->field_options ); |
| 559 | - $size = $f->field_options['size']; | |
| 396 | + $size = $f->field_options['size']; | |
| 560 | 397 | $this->maybe_convert_migrated_size( $size ); |
| 561 | 398 | |
| 562 | 399 | if ( $size === $f->field_options['size'] ) { |
| 563 | 400 | continue; |
| @@ -569,9 +406,8 @@ | ||
| 569 | 406 | } |
| 570 | 407 | |
| 571 | 408 | // reverse the extra size changes in widgets |
| 572 | 409 | $widgets = get_option( 'widget_frm_show_form' ); |
| 573 | - | |
| 574 | 410 | if ( empty( $widgets ) ) { |
| 575 | 411 | return; |
| 576 | 412 | } |
| 577 | 413 | |
| @@ -577,11 +413,8 @@ | ||
| 577 | 413 | |
| 578 | 414 | $this->revert_widget_field_size(); |
| 579 | 415 | } |
| 580 | 416 | |
| 581 | - /** | |
| 582 | - * @return array | |
| 583 | - */ | |
| 584 | 417 | private function get_fields_with_size() { |
| 585 | 418 | $field_types = array( |
| 586 | 419 | 'textarea', |
| 587 | 420 | 'text', |
| @@ -609,20 +442,16 @@ | ||
| 609 | 442 | /** |
| 610 | 443 | * Reverse the extra size changes in widgets |
| 611 | 444 | * |
| 612 | 445 | * @since 3.0.05 |
| 613 | - * | |
| 614 | - * @return void | |
| 615 | 446 | */ |
| 616 | 447 | private function revert_widget_field_size() { |
| 617 | 448 | $widgets = get_option( 'widget_frm_show_form' ); |
| 618 | - | |
| 619 | 449 | if ( empty( $widgets ) ) { |
| 620 | 450 | return; |
| 621 | 451 | } |
| 622 | 452 | |
| 623 | 453 | FrmAppHelper::unserialize_or_decode( $widgets ); |
| 624 | - | |
| 625 | 454 | foreach ( $widgets as $k => $widget ) { |
| 626 | 455 | if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
| 627 | 456 | continue; |
| 628 | 457 | } |
| @@ -635,22 +464,16 @@ | ||
| 635 | 464 | /** |
| 636 | 465 | * Divide by 9 to reverse the multiplication |
| 637 | 466 | * |
| 638 | 467 | * @since 3.0.05 |
| 639 | - * | |
| 640 | - * @param string $size Size string to maybe convert, passed by reference. | |
| 641 | - * | |
| 642 | - * @return void | |
| 643 | 468 | */ |
| 644 | 469 | private function maybe_convert_migrated_size( &$size ) { |
| 645 | 470 | $has_px_size = ! empty( $size ) && strpos( $size, 'px' ); |
| 646 | - | |
| 647 | 471 | if ( ! $has_px_size ) { |
| 648 | 472 | return; |
| 649 | 473 | } |
| 650 | 474 | |
| 651 | 475 | $int_size = str_replace( 'px', '', $size ); |
| 652 | - | |
| 653 | 476 | if ( ! is_numeric( $int_size ) || (int) $int_size < 900 ) { |
| 654 | 477 | return; |
| 655 | 478 | } |
| 656 | 479 | |
| @@ -663,22 +486,19 @@ | ||
| 663 | 486 | * Migrate old styling settings. If sites are using the old |
| 664 | 487 | * default 400px field width, switch it to 100% |
| 665 | 488 | * |
| 666 | 489 | * @since 2.0.4 |
| 667 | - * | |
| 668 | - * @return void | |
| 669 | 490 | */ |
| 670 | 491 | private function migrate_to_25() { |
| 671 | 492 | // get the style that was created with the style migration |
| 672 | 493 | $frm_style = new FrmStyle(); |
| 673 | 494 | $styles = $frm_style->get_all( 'post_date', 'ASC', 1 ); |
| 674 | - | |
| 675 | 495 | if ( empty( $styles ) ) { |
| 676 | 496 | return; |
| 677 | 497 | } |
| 678 | 498 | |
| 679 | 499 | foreach ( $styles as $style ) { |
| 680 | - if ( $style->post_content['field_width'] === '400px' ) { | |
| 500 | + if ( $style->post_content['field_width'] == '400px' ) { | |
| 681 | 501 | $style->post_content['field_width'] = '100%'; |
| 682 | 502 | $frm_style->save( (array) $style ); |
| 683 | 503 | |
| 684 | 504 | return; |
| @@ -690,15 +510,12 @@ | ||
| 690 | 510 | * Check if the parent_form_id columns exists. |
| 691 | 511 | * If not, try and add it again |
| 692 | 512 | * |
| 693 | 513 | * @since 2.0.2 |
| 694 | - * | |
| 695 | - * @return void | |
| 696 | 514 | */ |
| 697 | 515 | private function migrate_to_23() { |
| 698 | 516 | global $wpdb; |
| 699 | 517 | $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 700 | - | |
| 701 | 518 | if ( empty( $exists ) ) { |
| 702 | 519 | $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 703 | 520 | } |
| 704 | 521 | } |
| @@ -704,10 +521,8 @@ | ||
| 704 | 521 | } |
| 705 | 522 | |
| 706 | 523 | /** |
| 707 | 524 | * Change field size from character to pixel -- Multiply by 9 |
| 708 | - * | |
| 709 | - * @return void | |
| 710 | 525 | */ |
| 711 | 526 | private function migrate_to_17() { |
| 712 | 527 | $fields = $this->get_fields_with_size(); |
| 713 | 528 | |
| @@ -712,9 +527,8 @@ | ||
| 712 | 527 | $fields = $this->get_fields_with_size(); |
| 713 | 528 | |
| 714 | 529 | foreach ( $fields as $f ) { |
| 715 | 530 | FrmAppHelper::unserialize_or_decode( $f->field_options ); |
| 716 | - | |
| 717 | 531 | if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
| 718 | 532 | continue; |
| 719 | 533 | } |
| 720 | 534 | |
| @@ -728,20 +542,16 @@ | ||
| 728 | 542 | } |
| 729 | 543 | |
| 730 | 544 | /** |
| 731 | 545 | * Change the characters in widgets to pixels |
| 732 | - * | |
| 733 | - * @return void | |
| 734 | 546 | */ |
| 735 | 547 | private function adjust_widget_size() { |
| 736 | 548 | $widgets = get_option( 'widget_frm_show_form' ); |
| 737 | - | |
| 738 | 549 | if ( empty( $widgets ) ) { |
| 739 | 550 | return; |
| 740 | 551 | } |
| 741 | 552 | |
| 742 | 553 | FrmAppHelper::unserialize_or_decode( $widgets ); |
| 743 | - | |
| 744 | 554 | foreach ( $widgets as $k => $widget ) { |
| 745 | 555 | if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
| 746 | 556 | continue; |
| 747 | 557 | } |
| @@ -749,17 +559,12 @@ | ||
| 749 | 559 | } |
| 750 | 560 | update_option( 'widget_frm_show_form', $widgets ); |
| 751 | 561 | } |
| 752 | 562 | |
| 753 | - /** | |
| 754 | - * @param string $size | |
| 755 | - * | |
| 756 | - * @return void | |
| 757 | - */ | |
| 758 | 563 | private function convert_character_to_px( &$size ) { |
| 759 | 564 | $pixel_conversion = 9; |
| 760 | 565 | |
| 761 | - $size = round( $pixel_conversion * (int) $size ); | |
| 566 | + $size = round( $pixel_conversion * (int) $size ); | |
| 762 | 567 | $size .= 'px'; |
| 763 | 568 | } |
| 764 | 569 | |
| 765 | 570 | /** |
| @@ -829,13 +634,11 @@ | ||
| 829 | 634 | unset( $sending, $img ); |
| 830 | 635 | |
| 831 | 636 | $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
| 832 | 637 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 833 | - | |
| 834 | 638 | foreach ( $forms as $form ) { |
| 835 | 639 | FrmAppHelper::unserialize_or_decode( $form->options ); |
| 836 | - | |
| 837 | - if ( empty( $form->options['submit_html'] ) ) { | |
| 640 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { | |
| 838 | 641 | continue; |
| 839 | 642 | } |
| 840 | 643 | |
| 841 | 644 | if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |