| @@ -3,10 +3,8 @@ | ||
| 3 | 3 | * Handles the installation of a solution and any dependencies. |
| 4 | 4 | * This page is shown when a Formidable plugin is activated. |
| 5 | 5 | * |
| 6 | 6 | * @since 4.06.02 |
| 7 | - * | |
| 8 | - * @package Formidable | |
| 9 | 7 | */ |
| 10 | 8 | |
| 11 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | 10 | die( 'You are not allowed to call this page directly.' ); |
| @@ -13,16 +11,10 @@ | ||
| 13 | 11 | } |
| 14 | 12 | |
| 15 | 13 | class FrmSolution { |
| 16 | 14 | |
| 17 | - /** | |
| 18 | - * @var string | |
| 19 | - */ | |
| 20 | 15 | protected $plugin_slug = ''; |
| 21 | 16 | |
| 22 | - /** | |
| 23 | - * @var string | |
| 24 | - */ | |
| 25 | 17 | protected $plugin_file = ''; |
| 26 | 18 | |
| 27 | 19 | /** |
| 28 | 20 | * Hidden welcome page slug. |
| @@ -27,23 +19,15 @@ | ||
| 27 | 19 | /** |
| 28 | 20 | * Hidden welcome page slug. |
| 29 | 21 | * |
| 30 | 22 | * @since 4.06.02 |
| 31 | - * | |
| 32 | - * @var string | |
| 33 | 23 | */ |
| 34 | 24 | protected $page = ''; |
| 35 | 25 | |
| 36 | - /** | |
| 37 | - * @var string | |
| 38 | - */ | |
| 39 | - protected $icon = 'frmfont frm_settings_icon'; | |
| 26 | + protected $icon = 'frm_icon_font frm_settings_icon'; | |
| 40 | 27 | |
| 41 | - /** | |
| 42 | - * @param array $atts | |
| 43 | - */ | |
| 44 | 28 | public function __construct( $atts = array() ) { |
| 45 | - if ( ! $this->plugin_slug ) { | |
| 29 | + if ( empty( $this->plugin_slug ) ) { | |
| 46 | 30 | return; |
| 47 | 31 | } |
| 48 | 32 | |
| 49 | 33 | add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 ); |
| @@ -48,9 +32,9 @@ | ||
| 48 | 32 | |
| 49 | 33 | add_action( 'plugins_loaded', array( $this, 'load_hooks' ), 50 ); |
| 50 | 34 | add_action( 'admin_init', array( $this, 'redirect' ), 9999 ); |
| 51 | 35 | |
| 52 | - if ( ! $this->plugin_file ) { | |
| 36 | + if ( empty( $this->plugin_file ) ) { | |
| 53 | 37 | $this->plugin_file = $this->plugin_slug . '.php'; |
| 54 | 38 | } |
| 55 | 39 | } |
| 56 | 40 | |
| @@ -82,16 +66,11 @@ | ||
| 82 | 66 | add_action( 'admin_menu', array( $this, 'register' ) ); |
| 83 | 67 | add_action( 'admin_head', array( $this, 'hide_menu' ) ); |
| 84 | 68 | } |
| 85 | 69 | |
| 86 | - /** | |
| 87 | - * @param array $links | |
| 88 | - * | |
| 89 | - * @return array | |
| 90 | - */ | |
| 91 | 70 | public function plugin_links( $links ) { |
| 92 | 71 | if ( ! $this->is_complete() ) { |
| 93 | - $settings = '<a href="' . esc_url( $this->settings_link() ) . '">' . esc_html__( 'Setup', 'formidable' ) . '</a>'; | |
| 72 | + $settings = '<a href="' . esc_url( $this->settings_link() ) . '">' . __( 'Setup', 'formidable' ) . '</a>'; | |
| 94 | 73 | array_unshift( $links, $settings ); |
| 95 | 74 | } |
| 96 | 75 | |
| 97 | 76 | return $links; |
| @@ -107,8 +86,9 @@ | ||
| 107 | 86 | * |
| 108 | 87 | * @return void |
| 109 | 88 | */ |
| 110 | 89 | public function register() { |
| 90 | + | |
| 111 | 91 | // Getting started - shows after installation. |
| 112 | 92 | add_dashboard_page( |
| 113 | 93 | esc_html( $this->page_title() ), |
| 114 | 94 | esc_html( $this->page_title() ), |
| @@ -164,10 +144,10 @@ | ||
| 164 | 144 | * |
| 165 | 145 | * @return void |
| 166 | 146 | */ |
| 167 | 147 | public function redirect() { |
| 148 | + | |
| 168 | 149 | $current_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 169 | - | |
| 170 | 150 | if ( $current_page === $this->page ) { |
| 171 | 151 | // Prevent endless loop. |
| 172 | 152 | return; |
| 173 | 153 | } |
| @@ -181,9 +161,9 @@ | ||
| 181 | 161 | if ( ! $this->is_current_plugin() ) { |
| 182 | 162 | return; |
| 183 | 163 | } |
| 184 | 164 | |
| 185 | - delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME ); | |
| 165 | + delete_transient( 'frm_activation_redirect' ); | |
| 186 | 166 | |
| 187 | 167 | // Initial install. |
| 188 | 168 | wp_safe_redirect( $this->settings_link() ); |
| 189 | 169 | exit; |
| @@ -195,14 +175,10 @@ | ||
| 195 | 175 | protected function settings_link() { |
| 196 | 176 | return admin_url( 'index.php?page=' . $this->page ); |
| 197 | 177 | } |
| 198 | 178 | |
| 199 | - /** | |
| 179 | + /* | |
| 200 | 180 | * Add page to global settings. |
| 201 | - * | |
| 202 | - * @param array $sections Sections. | |
| 203 | - * | |
| 204 | - * @return array | |
| 205 | 181 | */ |
| 206 | 182 | public function add_settings( $sections ) { |
| 207 | 183 | wp_enqueue_style( 'formidable-pro-fields' ); |
| 208 | 184 | $sections[ $this->plugin_slug ] = array( |
| @@ -222,9 +198,8 @@ | ||
| 222 | 198 | * @return void |
| 223 | 199 | */ |
| 224 | 200 | public function settings_page() { |
| 225 | 201 | $steps = $this->get_steps_data(); |
| 226 | - | |
| 227 | 202 | if ( ! $steps['license']['complete'] || ( isset( $steps['plugin'] ) && ! $steps['plugin']['complete'] ) ) { |
| 228 | 203 | // Redirect to the welcome page if install hasn't been done. |
| 229 | 204 | $url = $this->settings_link(); |
| 230 | 205 | echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>'; |
| @@ -230,9 +205,10 @@ | ||
| 230 | 205 | echo '<script>window.location.replace("' . esc_url_raw( $url ) . '");</script>'; |
| 231 | 206 | return; |
| 232 | 207 | } |
| 233 | 208 | |
| 234 | - $all_imported = $this->is_complete( 'all' ); | |
| 209 | + $all_imported = $this->is_complete( 'all' ); | |
| 210 | + | |
| 235 | 211 | $step = $steps['import']; |
| 236 | 212 | $step['label'] = ''; |
| 237 | 213 | $step['nested'] = true; |
| 238 | 214 | |
| @@ -239,27 +215,22 @@ | ||
| 239 | 215 | if ( $steps['complete']['current'] ) { |
| 240 | 216 | // Always show this step in settings. |
| 241 | 217 | $step['current'] = true; |
| 242 | 218 | |
| 243 | - $new_class = $all_imported ? ' button frm_hidden' : ''; | |
| 219 | + $new_class = $all_imported ? ' button frm_hidden' : ''; | |
| 244 | 220 | $step['button_class'] = str_replace( 'frm_grey disabled', $new_class, $step['button_class'] ); |
| 245 | 221 | } |
| 246 | - | |
| 247 | 222 | if ( $all_imported ) { |
| 248 | 223 | $step['description'] = __( 'The following form(s) have been created.', 'formidable' ); |
| 249 | 224 | } |
| 250 | - | |
| 251 | 225 | $this->show_app_install( $step ); |
| 252 | 226 | |
| 253 | - if ( $all_imported ) { | |
| 254 | - return; | |
| 227 | + if ( ! $all_imported ) { | |
| 228 | + $step = $steps['complete']; | |
| 229 | + $step['current'] = false; | |
| 230 | + $step['button_class'] .= ' frm_grey disabled'; | |
| 231 | + $this->show_page_links( $step ); | |
| 255 | 232 | } |
| 256 | - | |
| 257 | - $step = $steps['complete']; | |
| 258 | - $step['current'] = false; | |
| 259 | - $step['button_class'] .= ' frm_grey disabled'; | |
| 260 | - | |
| 261 | - $this->show_page_links( $step ); | |
| 262 | 233 | } |
| 263 | 234 | |
| 264 | 235 | /** |
| 265 | 236 | * Getting Started screen. Shows after first install. |
| @@ -289,9 +260,8 @@ | ||
| 289 | 260 | 'height' => 90, |
| 290 | 261 | 'width' => 90, |
| 291 | 262 | ); |
| 292 | 263 | |
| 293 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 294 | 264 | ?> |
| 295 | 265 | <section class="top"> |
| 296 | 266 | <div class="frm-smtp-logos"> |
| 297 | 267 | <?php FrmAppHelper::show_logo( $size ); ?> |
| @@ -315,9 +285,8 @@ | ||
| 315 | 285 | <h1><?php echo esc_html( $this->page_title() ); ?></h1> |
| 316 | 286 | <p><?php echo esc_html( $this->page_description() ); ?></p> |
| 317 | 287 | </section> |
| 318 | 288 | <?php |
| 319 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 320 | 289 | } |
| 321 | 290 | |
| 322 | 291 | /** |
| 323 | 292 | * This is the welcome page content. |
| @@ -327,9 +296,8 @@ | ||
| 327 | 296 | */ |
| 328 | 297 | protected function main_content() { |
| 329 | 298 | $steps = $this->get_steps_data(); |
| 330 | 299 | $this->license_box( $steps['license'] ); |
| 331 | - | |
| 332 | 300 | if ( isset( $steps['plugin'] ) ) { |
| 333 | 301 | $this->show_plugin_install( $steps['plugin'] ); |
| 334 | 302 | } |
| 335 | 303 | $this->show_app_install( $steps['import'] ); |
| @@ -335,44 +303,41 @@ | ||
| 335 | 303 | $this->show_app_install( $steps['import'] ); |
| 336 | 304 | $this->show_page_links( $steps['complete'] ); |
| 337 | 305 | } |
| 338 | 306 | |
| 339 | - /** | |
| 340 | - * @return array | |
| 341 | - */ | |
| 342 | 307 | protected function get_steps_data() { |
| 343 | 308 | $pro_installed = FrmAppHelper::pro_is_connected(); |
| 344 | 309 | |
| 345 | 310 | $steps = array( |
| 346 | - 'license' => array( | |
| 347 | - 'label' => __( 'Connect to FormidableForms.com', 'formidable' ), | |
| 348 | - 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ), | |
| 349 | - 'button_label' => __( 'Connect an Account', 'formidable' ), | |
| 350 | - 'current' => ! $pro_installed, | |
| 351 | - 'complete' => $pro_installed, | |
| 352 | - 'num' => 1, | |
| 311 | + 'license' => array( | |
| 312 | + 'label' => __( 'Connect to FormidableForms.com', 'formidable' ), | |
| 313 | + 'description' => __( 'Create a connection to get plugin downloads.', 'formidable' ), | |
| 314 | + 'button_label' => __( 'Connect an Account', 'formidable' ), | |
| 315 | + 'current' => empty( $pro_installed ), | |
| 316 | + 'complete' => $pro_installed, | |
| 317 | + 'num' => 1, | |
| 353 | 318 | ), |
| 354 | - 'plugin' => array( | |
| 355 | - 'label' => __( 'Install and Activate Add-Ons', 'formidable' ), | |
| 356 | - 'description' => __( 'Install any required add-ons from FormidableForms.com.', 'formidable' ), | |
| 357 | - 'button_label' => __( 'Install & Activate', 'formidable' ), | |
| 358 | - 'current' => false, | |
| 359 | - 'complete' => false, | |
| 360 | - 'num' => 2, | |
| 319 | + 'plugin' => array( | |
| 320 | + 'label' => __( 'Install and Activate Add-Ons', 'formidable' ), | |
| 321 | + 'description' => __( 'Install any required add-ons from FormidableForms.com.', 'formidable' ), | |
| 322 | + 'button_label' => __( 'Install & Activate', 'formidable' ), | |
| 323 | + 'current' => false, | |
| 324 | + 'complete' => false, | |
| 325 | + 'num' => 2, | |
| 361 | 326 | ), |
| 362 | - 'import' => array( | |
| 363 | - 'label' => __( 'Setup Forms, Views, and Pages', 'formidable' ), | |
| 364 | - 'description' => __( 'Build the forms, views, and pages automatically.', 'formidable' ), | |
| 365 | - 'button_label' => __( 'Create Now', 'formidable' ), | |
| 366 | - 'complete' => $this->is_complete(), | |
| 367 | - 'num' => 3, | |
| 327 | + 'import' => array( | |
| 328 | + 'label' => __( 'Setup Forms, Views, and Pages', 'formidable' ), | |
| 329 | + 'description' => __( 'Build the forms, views, and pages automatically.', 'formidable' ), | |
| 330 | + 'button_label' => __( 'Create Now', 'formidable' ), | |
| 331 | + 'complete' => $this->is_complete(), | |
| 332 | + 'num' => 3, | |
| 368 | 333 | ), |
| 369 | 334 | 'complete' => array( |
| 370 | - 'label' => __( 'Customize Your New Pages', 'formidable' ), | |
| 371 | - 'description' => __( 'Make any required changes and publish the page.', 'formidable' ), | |
| 372 | - 'button_label' => __( 'View Page', 'formidable' ), | |
| 373 | - 'complete' => false, | |
| 374 | - 'num' => 4, | |
| 335 | + 'label' => __( 'Customize Your New Pages', 'formidable' ), | |
| 336 | + 'description' => __( 'Make any required changes and publish the page.', 'formidable' ), | |
| 337 | + 'button_label' => __( 'View Page', 'formidable' ), | |
| 338 | + 'complete' => false, | |
| 339 | + 'num' => 4, | |
| 375 | 340 | ), |
| 376 | 341 | ); |
| 377 | 342 | |
| 378 | 343 | $this->adjust_plugin_install_step( $steps ); |
| @@ -377,9 +342,8 @@ | ||
| 377 | 342 | |
| 378 | 343 | $this->adjust_plugin_install_step( $steps ); |
| 379 | 344 | |
| 380 | 345 | $has_current = false; |
| 381 | - | |
| 382 | 346 | foreach ( $steps as $k => $step ) { |
| 383 | 347 | // Set the current step. |
| 384 | 348 | if ( ! isset( $step['current'] ) ) { |
| 385 | 349 | if ( $step['complete'] ) { |
| @@ -385,9 +349,9 @@ | ||
| 385 | 349 | if ( $step['complete'] ) { |
| 386 | 350 | $steps[ $k ]['current'] = false; |
| 387 | 351 | } else { |
| 388 | 352 | $steps[ $k ]['current'] = ! $has_current; |
| 389 | - $has_current = true; | |
| 353 | + $has_current = true; | |
| 390 | 354 | } |
| 391 | 355 | } elseif ( $step['current'] ) { |
| 392 | 356 | $has_current = true; |
| 393 | 357 | } |
| @@ -392,16 +356,15 @@ | ||
| 392 | 356 | $has_current = true; |
| 393 | 357 | } |
| 394 | 358 | |
| 395 | 359 | // Set disabled buttons. |
| 396 | - $class = $step['button_class'] ?? ''; | |
| 360 | + $class = isset( $step['button_class'] ) ? $step['button_class'] : ''; | |
| 397 | 361 | $class .= ' button-primary frm-button-primary'; |
| 398 | - | |
| 399 | 362 | if ( ! $steps[ $k ]['current'] ) { |
| 400 | 363 | $class .= ' frm_grey disabled'; |
| 401 | 364 | } |
| 402 | 365 | $steps[ $k ]['button_class'] = $class; |
| 403 | - }//end foreach | |
| 366 | + } | |
| 404 | 367 | |
| 405 | 368 | return $steps; |
| 406 | 369 | } |
| 407 | 370 | |
| @@ -411,10 +374,9 @@ | ||
| 411 | 374 | * @return void |
| 412 | 375 | */ |
| 413 | 376 | protected function adjust_plugin_install_step( &$steps ) { |
| 414 | 377 | $plugins = $this->required_plugins(); |
| 415 | - | |
| 416 | - if ( ! $plugins ) { | |
| 378 | + if ( empty( $plugins ) ) { | |
| 417 | 379 | unset( $steps['plugin'] ); |
| 418 | 380 | $steps['import']['num'] = 2; |
| 419 | 381 | $steps['complete']['num'] = 3; |
| 420 | 382 | return; |
| @@ -421,16 +383,14 @@ | ||
| 421 | 383 | } |
| 422 | 384 | |
| 423 | 385 | $missing = array(); |
| 424 | 386 | $rel = array(); |
| 425 | - | |
| 426 | 387 | foreach ( $plugins as $plugin_key ) { |
| 427 | 388 | $plugin = FrmAddonsController::install_link( $plugin_key ); |
| 428 | - | |
| 429 | 389 | if ( $plugin['status'] === 'active' ) { |
| 430 | 390 | continue; |
| 431 | 391 | } |
| 432 | - | |
| 392 | + $links[ $plugin_key ] = $plugin; | |
| 433 | 393 | if ( isset( $plugin['url'] ) ) { |
| 434 | 394 | $rel[] = $plugin['url']; |
| 435 | 395 | } else { |
| 436 | 396 | // Add-on is required but not allowed. |
| @@ -436,12 +396,11 @@ | ||
| 436 | 396 | // Add-on is required but not allowed. |
| 437 | 397 | $missing[] = $plugin_key; |
| 438 | 398 | } |
| 439 | 399 | } |
| 440 | - | |
| 441 | - if ( ! $rel && ! $missing ) { | |
| 400 | + if ( empty( $rel ) && empty( $missing ) ) { | |
| 442 | 401 | $steps['plugin']['complete'] = true; |
| 443 | - } elseif ( $missing ) { | |
| 402 | + } elseif ( ! empty( $missing ) ) { | |
| 444 | 403 | $steps['plugin']['error'] = sprintf( |
| 445 | 404 | /* translators: %1$s: Plugin name */ |
| 446 | 405 | esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ), |
| 447 | 406 | implode( ', ', $missing ) |
| @@ -446,9 +405,9 @@ | ||
| 446 | 405 | esc_html__( 'You need permission to download the Formidable %1$s plugin', 'formidable' ), |
| 447 | 406 | implode( ', ', $missing ) |
| 448 | 407 | ); |
| 449 | 408 | } else { |
| 450 | - $steps['plugin']['links'] = $rel; | |
| 409 | + $steps['plugin']['links'] = $rel; | |
| 451 | 410 | $steps['plugin']['button_class'] = 'frm-solution-multiple '; |
| 452 | 411 | } |
| 453 | 412 | |
| 454 | 413 | if ( $steps['license']['complete'] && ! $steps['plugin']['complete'] ) { |
| @@ -456,21 +415,18 @@ | ||
| 456 | 415 | } |
| 457 | 416 | } |
| 458 | 417 | |
| 459 | 418 | /** |
| 460 | - * @param array $step Step. | |
| 461 | - * | |
| 462 | 419 | * @return void |
| 463 | 420 | */ |
| 464 | 421 | protected function step_top( $step ) { |
| 465 | - $section_class = ! empty( $step['current'] ) ? '' : 'frm_grey'; | |
| 422 | + $section_class = ( ! isset( $step['current'] ) || ! $step['current'] ) ? 'frm_grey' : ''; | |
| 466 | 423 | |
| 467 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 468 | 424 | ?> |
| 469 | 425 | <section class="step step-install <?php echo esc_attr( $section_class ); ?>"> |
| 470 | 426 | <aside class="num"> |
| 471 | 427 | <?php |
| 472 | - if ( ! empty( $step['complete'] ) ) { | |
| 428 | + if ( isset( $step['complete'] ) && $step['complete'] ) { | |
| 473 | 429 | FrmAppHelper::icon_by_class( |
| 474 | 430 | 'frmfont frm_step_complete_icon', |
| 475 | 431 | array( |
| 476 | 432 | /* translators: %1$s: Step number */ |
| @@ -479,9 +435,9 @@ | ||
| 479 | 435 | ) |
| 480 | 436 | ); |
| 481 | 437 | } else { |
| 482 | 438 | ?> |
| 483 | - <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 100 100"><circle cx="50" cy="50" r="50" fill="#ccc"/><text x="50%" y="50%" text-anchor="middle" fill="#fff" stroke="#fff" stroke-width="2px" dy=".3em" font-size="3.7em"><?php echo esc_html( $step['num'] ); ?></text></svg><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 439 | + <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 100 100"><circle cx="50" cy="50" r="50" fill="#ccc"/><text x="50%" y="50%" text-anchor="middle" fill="#fff" stroke="#fff" stroke-width="2px" dy=".3em" font-size="3.7em"><?php echo esc_html( $step['num'] ); ?></text></svg> | |
| 484 | 440 | <?php |
| 485 | 441 | } |
| 486 | 442 | ?> |
| 487 | 443 | <i class="loader hidden"></i> |
| @@ -494,30 +450,23 @@ | ||
| 494 | 450 | <?php if ( isset( $step['error'] ) ) { ?> |
| 495 | 451 | <p class="frm_error"><?php echo esc_html( $step['error'] ); ?></p> |
| 496 | 452 | <?php } ?> |
| 497 | 453 | <?php |
| 498 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 499 | 454 | } |
| 500 | 455 | |
| 501 | 456 | /** |
| 502 | - * @param array $step Step. | |
| 503 | - * | |
| 504 | 457 | * @return void |
| 505 | 458 | */ |
| 506 | 459 | protected function step_bottom( $step ) { |
| 507 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 508 | 460 | ?> |
| 509 | 461 | </div> |
| 510 | 462 | </section> |
| 511 | 463 | <?php |
| 512 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 513 | 464 | } |
| 514 | 465 | |
| 515 | 466 | /** |
| 516 | 467 | * Generate and output Connect step section HTML. |
| 517 | 468 | * |
| 518 | - * @param array $step Step. | |
| 519 | - * | |
| 520 | 469 | * @return void |
| 521 | 470 | */ |
| 522 | 471 | protected function license_box( $step ) { |
| 523 | 472 | $this->step_top( $step ); |
| @@ -522,15 +471,13 @@ | ||
| 522 | 471 | protected function license_box( $step ) { |
| 523 | 472 | $this->step_top( $step ); |
| 524 | 473 | |
| 525 | 474 | if ( $step['complete'] ) { |
| 526 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 527 | 475 | ?> |
| 528 | 476 | <a href="#" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 529 | 477 | <?php echo esc_html( $step['button_label'] ); ?> |
| 530 | 478 | </a> |
| 531 | 479 | <?php |
| 532 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 533 | 480 | } else { |
| 534 | 481 | FrmSettingsController::license_box(); |
| 535 | 482 | } |
| 536 | 483 | |
| @@ -537,10 +484,8 @@ | ||
| 537 | 484 | $this->step_bottom( $step ); |
| 538 | 485 | } |
| 539 | 486 | |
| 540 | 487 | /** |
| 541 | - * @param array $step Step. | |
| 542 | - * | |
| 543 | 488 | * @return void |
| 544 | 489 | */ |
| 545 | 490 | protected function show_plugin_install( $step ) { |
| 546 | 491 | $this->step_top( $step ); |
| @@ -545,17 +490,15 @@ | ||
| 545 | 490 | protected function show_plugin_install( $step ) { |
| 546 | 491 | $this->step_top( $step ); |
| 547 | 492 | |
| 548 | 493 | if ( ! isset( $step['error'] ) ) { |
| 549 | - $rel = $step['links'] ?? array(); | |
| 494 | + $rel = isset( $step['links'] ) ? $step['links'] : array(); | |
| 550 | 495 | |
| 551 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 552 | 496 | ?> |
| 553 | 497 | <a rel="<?php echo esc_attr( implode( ',', $rel ) ); ?>" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 554 | 498 | <?php echo esc_html( $step['button_label'] ); ?> |
| 555 | 499 | </a> |
| 556 | 500 | <?php |
| 557 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 558 | 501 | } |
| 559 | 502 | |
| 560 | 503 | $this->step_bottom( $step ); |
| 561 | 504 | } |
| @@ -560,27 +503,24 @@ | ||
| 560 | 503 | $this->step_bottom( $step ); |
| 561 | 504 | } |
| 562 | 505 | |
| 563 | 506 | /** |
| 564 | - * @param array $step Step. | |
| 565 | - * | |
| 566 | 507 | * @return void |
| 567 | 508 | */ |
| 568 | 509 | protected function show_app_install( $step ) { |
| 569 | 510 | $is_complete = $step['complete']; |
| 570 | - | |
| 571 | - if ( $this->form_options() && ! $is_complete ) { | |
| 511 | + if ( ! empty( $this->form_options() ) && ! $is_complete ) { | |
| 572 | 512 | $step['description'] = __( 'Select the form or view you would like to create.', 'formidable' ); |
| 573 | 513 | } |
| 574 | 514 | |
| 575 | 515 | $this->step_top( $step ); |
| 576 | 516 | |
| 577 | - $api = new FrmFormApi(); | |
| 578 | - $addons = $api->get_api_info(); | |
| 579 | - $id = $this->download_id(); | |
| 517 | + $api = new FrmFormApi(); | |
| 518 | + $addons = $api->get_api_info(); | |
| 519 | + | |
| 520 | + $id = $this->download_id(); | |
| 580 | 521 | $has_file = isset( $addons[ $id ] ) && isset( $addons[ $id ]['beta'] ); |
| 581 | 522 | |
| 582 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 583 | 523 | if ( ! $step['current'] ) { |
| 584 | 524 | ?> |
| 585 | 525 | <a href="#" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 586 | 526 | <?php echo esc_html( $step['button_label'] ); ?> |
| @@ -593,12 +533,11 @@ | ||
| 593 | 533 | |
| 594 | 534 | if ( ! $has_file ) { |
| 595 | 535 | echo '<p class="frm_error_style">' . esc_html__( 'We didn\'t find anything to import. Please contact our team.', 'formidable' ) . '</p>'; |
| 596 | 536 | } elseif ( ! isset( $addons[ $id ]['beta']['package'] ) ) { |
| 597 | - echo '<p class="frm_error_style">' . esc_html__( 'Looks like you may not have a current subscription for this solution. Please check your account.', 'formidable' ) . '</p>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 537 | + echo '<p class="frm_error_style">' . esc_html__( 'Looks like you may not have a current subscription for this solution. Please check your account.', 'formidable' ) . '</p>'; | |
| 598 | 538 | } else { |
| 599 | 539 | $xml = $addons[ $id ]['beta']['package']; |
| 600 | - | |
| 601 | 540 | if ( is_array( $xml ) ) { |
| 602 | 541 | $xml = reset( $xml ); |
| 603 | 542 | } |
| 604 | 543 | |
| @@ -635,17 +574,14 @@ | ||
| 635 | 574 | echo '</fieldset>'; |
| 636 | 575 | } else { |
| 637 | 576 | echo '</form>'; |
| 638 | 577 | } |
| 639 | - }//end if | |
| 640 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 578 | + } | |
| 641 | 579 | |
| 642 | 580 | $this->step_bottom( $step ); |
| 643 | 581 | } |
| 644 | 582 | |
| 645 | 583 | /** |
| 646 | - * @param string $xml | |
| 647 | - * | |
| 648 | 584 | * @return void |
| 649 | 585 | */ |
| 650 | 586 | protected function show_form_options( $xml ) { |
| 651 | 587 | $this->show_import_options( $this->form_options(), 'form', $xml ); |
| @@ -658,11 +594,9 @@ | ||
| 658 | 594 | $this->show_import_options( $this->view_options(), 'view' ); |
| 659 | 595 | } |
| 660 | 596 | |
| 661 | 597 | /** |
| 662 | - * @param array $options | |
| 663 | 598 | * @param string $importing |
| 664 | - * @param string $xml | |
| 665 | 599 | * |
| 666 | 600 | * @psalm-param 'form'|'view' $importing |
| 667 | 601 | * |
| 668 | 602 | * @return void |
| @@ -667,28 +601,26 @@ | ||
| 667 | 601 | * |
| 668 | 602 | * @return void |
| 669 | 603 | */ |
| 670 | 604 | protected function show_import_options( $options, $importing, $xml = '' ) { |
| 671 | - if ( ! $options ) { | |
| 605 | + if ( empty( $options ) ) { | |
| 672 | 606 | return; |
| 673 | 607 | } |
| 674 | 608 | |
| 675 | 609 | $imported = $this->previously_imported_forms(); |
| 676 | 610 | $count = count( $options ); |
| 677 | - | |
| 678 | 611 | foreach ( $options as $info ) { |
| 679 | 612 | // Count the number of options displayed for css. |
| 680 | 613 | if ( $count > 1 && ! isset( $info['img'] ) ) { |
| 681 | - --$count; | |
| 614 | + $count --; | |
| 682 | 615 | } |
| 683 | 616 | } |
| 684 | - | |
| 685 | 617 | $width = floor( ( 533 - ( ( $count - 1 ) * 20 ) ) / $count ); |
| 686 | 618 | unset( $count ); |
| 687 | 619 | |
| 688 | 620 | $selected = false; |
| 689 | 621 | |
| 690 | - include FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php'; | |
| 622 | + include( FrmAppHelper::plugin_path() . '/classes/views/solutions/_import.php' ); | |
| 691 | 623 | } |
| 692 | 624 | |
| 693 | 625 | /** |
| 694 | 626 | * @return void |
| @@ -694,32 +626,26 @@ | ||
| 694 | 626 | * @return void |
| 695 | 627 | */ |
| 696 | 628 | protected function show_page_options() { |
| 697 | 629 | $pages = $this->needed_pages(); |
| 698 | - | |
| 699 | - if ( ! $pages ) { | |
| 630 | + if ( empty( $pages ) ) { | |
| 700 | 631 | return; |
| 701 | 632 | } |
| 702 | 633 | |
| 703 | 634 | echo '<h3>Choose New Page Title</h3>'; |
| 704 | - | |
| 705 | 635 | foreach ( $pages as $page ) { |
| 706 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 707 | 636 | ?> |
| 708 | 637 | <p> |
| 709 | 638 | <label for="pages_<?php echo esc_html( $page['type'] ); ?>"> |
| 710 | 639 | <?php echo esc_html( $page['label'] ); ?> |
| 711 | 640 | </label> |
| 712 | - <input type="text" name="pages[<?php echo esc_html( $page['type'] ); ?>]" value="<?php echo esc_attr( $page['name'] ); ?>" id="pages_<?php echo esc_html( $page['type'] ); ?>" required /><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 641 | + <input type="text" name="pages[<?php echo esc_html( $page['type'] ); ?>]" value="<?php echo esc_attr( $page['name'] ); ?>" id="pages_<?php echo esc_html( $page['type'] ); ?>" required /> | |
| 713 | 642 | </p> |
| 714 | 643 | <?php |
| 715 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 716 | 644 | } |
| 717 | 645 | } |
| 718 | 646 | |
| 719 | 647 | /** |
| 720 | - * @param array $step | |
| 721 | - * | |
| 722 | 648 | * @return void |
| 723 | 649 | */ |
| 724 | 650 | protected function show_page_links( $step ) { |
| 725 | 651 | if ( $step['current'] ) { |
| @@ -727,15 +653,13 @@ | ||
| 727 | 653 | } |
| 728 | 654 | |
| 729 | 655 | $this->step_top( $step ); |
| 730 | 656 | |
| 731 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 732 | 657 | ?> |
| 733 | 658 | <a href="#" target="_blank" rel="noopener" id="frm-redirect-link" class="<?php echo esc_attr( $step['button_class'] ); ?>"> |
| 734 | 659 | <?php echo esc_html( $step['button_label'] ); ?> |
| 735 | 660 | </a> |
| 736 | 661 | <?php |
| 737 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 738 | 662 | |
| 739 | 663 | $this->step_bottom( $step ); |
| 740 | 664 | } |
| 741 | 665 | |
| @@ -744,10 +668,10 @@ | ||
| 744 | 668 | * |
| 745 | 669 | * @return bool |
| 746 | 670 | */ |
| 747 | 671 | protected function is_current_plugin() { |
| 748 | - $to_redirect = get_transient( FrmOnboardingWizardController::TRANSIENT_NAME ); | |
| 749 | - return $to_redirect === $this->plugin_slug && ! $this->is_complete(); | |
| 672 | + $to_redirect = get_transient( 'frm_activation_redirect' ); | |
| 673 | + return $to_redirect === $this->plugin_slug && empty( $this->is_complete() ); | |
| 750 | 674 | } |
| 751 | 675 | |
| 752 | 676 | /** |
| 753 | 677 | * Override this function to indicate when install is complete. |
| @@ -759,13 +683,11 @@ | ||
| 759 | 683 | * @return bool |
| 760 | 684 | */ |
| 761 | 685 | protected function is_complete( $count = 1 ) { |
| 762 | 686 | $imported = $this->previously_imported_forms(); |
| 763 | - | |
| 764 | 687 | if ( $count === 'all' ) { |
| 765 | 688 | return count( $imported ) >= count( $this->form_options() ); |
| 766 | 689 | } |
| 767 | - | |
| 768 | 690 | return ! empty( $imported ); |
| 769 | 691 | } |
| 770 | 692 | |
| 771 | 693 | /** |
| @@ -775,12 +697,10 @@ | ||
| 775 | 697 | */ |
| 776 | 698 | protected function previously_imported_forms() { |
| 777 | 699 | $imported = array(); |
| 778 | 700 | $forms = $this->form_options(); |
| 779 | - | |
| 780 | 701 | foreach ( $forms as $form ) { |
| 781 | 702 | $was_imported = isset( $form['form'] ) ? FrmForm::get_id_by_key( $form['form'] ) : false; |
| 782 | - | |
| 783 | 703 | if ( $was_imported ) { |
| 784 | 704 | $imported[ $form['form'] ] = $was_imported; |
| 785 | 705 | } |
| 786 | 706 | } |
| @@ -861,8 +781,10 @@ | ||
| 861 | 781 | wp_enqueue_style( 'formidable-pro-fields' ); |
| 862 | 782 | ?> |
| 863 | 783 | <style> |
| 864 | 784 | #frm-welcome *, #frm-welcome *::before, #frm-welcome *::after { |
| 785 | + -webkit-box-sizing: border-box; | |
| 786 | + -moz-box-sizing: border-box; | |
| 865 | 787 | box-sizing: border-box; |
| 866 | 788 | } |
| 867 | 789 | #frm-welcome{ |
| 868 | 790 | width: 700px; |
| @@ -921,8 +843,10 @@ | ||
| 921 | 843 | border-radius: 3px; |
| 922 | 844 | } |
| 923 | 845 | #frm-welcome .step, |
| 924 | 846 | #frm-welcome .screenshot .cont { |
| 847 | + -webkit-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05); | |
| 848 | + -moz-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05); | |
| 925 | 849 | box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05); |
| 926 | 850 | } |
| 927 | 851 | #frm-welcome .step { |
| 928 | 852 | background-color: #F9F9F9; |
| @@ -965,5 +889,6 @@ | ||
| 965 | 889 | } |
| 966 | 890 | </style> |
| 967 | 891 | <?php |
| 968 | 892 | } |
| 893 | + | |
| 969 | 894 | } |