PluginProbe
Polylang / 3.7.7
Polylang v3.7.7
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | modules/wizard/wizard.php +97 -73 3.03.7.7 View file →
@@ -2,8 +2,12 @@
2 2 /**
3 3 * @package Polylang
4 4 */
5 5
6 +defined( 'ABSPATH' ) || exit;
7 +
8 +use WP_Syntex\Polylang\Options\Options;
9 +
6 10 /**
7 11 * Main class for Polylang wizard.
8 12 *
9 13 * @since 2.7
@@ -25,14 +29,18 @@
25 29
26 30 /**
27 31 * List of steps.
28 32 *
29 - * @var array $steps {
30 - * @type string $name I18n string which names the step.
31 - * @type callable $view The callback function use to display the step content.
32 - * @type callable $handler The callback function use to process the step after it is submitted.
33 - * @type array $scripts List of scripts handle needed by the step.
34 - * @type array $styles The list of styles handle needed by the step.
33 + * @var array[] $steps {
34 + * @type array {
35 + * List of step properties.
36 + *
37 + * @type string $name I18n string which names the step.
38 + * @type callable $view The callback function use to display the step content.
39 + * @type callable $handler The callback function use to process the step after it is submitted.
40 + * @type array $scripts List of scripts handle needed by the step.
41 + * @type array $styles The list of styles handle needed by the step.
42 + * }
35 43 * }
36 44 */
37 45 protected $steps = array();
38 46
@@ -38,11 +46,11 @@
38 46
39 47 /**
40 48 * The current step.
41 49 *
42 - * @var string
50 + * @var string|null
43 51 */
44 - protected $step;
52 + protected $current_step;
45 53
46 54 /**
47 55 * List of WordPress CSS file handles.
48 56 *
@@ -60,9 +68,9 @@
60 68 $this->options = &$polylang->options;
61 69 $this->model = &$polylang->model;
62 70
63 71 // Display Wizard page before any other action to ensure displaying it outside the WordPress admin context.
64 - // Hooked on admin_init with priority 40 to ensure PLL_Wizard_Pro is corretly initialized.
72 + // Hooked on admin_init with priority 40 to ensure PLL_Wizard_Pro is correctly initialized.
65 73 add_action( 'admin_init', array( $this, 'setup_wizard_page' ), 40 );
66 74 // Add Wizard submenu.
67 75 add_filter( 'pll_settings_tabs', array( $this, 'settings_tabs' ), 10, 1 );
68 76 // Add filter to select screens where to display the notice.
@@ -85,11 +93,11 @@
85 93 * @param bool $network_wide if activated for all sites in the network.
86 94 * @return void
87 95 */
88 96 public static function start_wizard( $network_wide ) {
89 - $options = get_option( 'polylang' );
97 + $options = (array) get_option( Options::OPTION_NAME, array() );
90 98
91 - if ( wp_doing_ajax() || $network_wide || ! empty( $options ) ) {
99 + if ( wp_doing_ajax() || $network_wide || ! empty( $options['version'] ) ) {
92 100 return;
93 101 }
94 102 set_transient( 'pll_activation_redirect', 1, 30 );
95 103 }
@@ -103,9 +111,9 @@
103 111 */
104 112 public function redirect_to_wizard() {
105 113 if ( get_transient( 'pll_activation_redirect' ) ) {
106 114 $do_redirect = true;
107 - if ( ( isset( $_GET['page'] ) && 'mlang_wizard' === sanitize_key( $_GET['page'] ) || isset( $_GET['activate-multi'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
115 + if ( ( isset( $_GET['page'] ) && 'mlang_wizard' === sanitize_key( $_GET['page'] ) ) || isset( $_GET['activate-multi'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
108 116 delete_transient( 'pll_activation_redirect' );
109 117 $do_redirect = false;
110 118 }
111 119
@@ -110,9 +118,9 @@
110 118 }
111 119
112 120 if ( $do_redirect ) {
113 121 wp_safe_redirect(
114 - esc_url_raw(
122 + sanitize_url(
115 123 add_query_arg(
116 124 array(
117 125 'page' => 'mlang_wizard',
118 126 ),
@@ -200,26 +208,26 @@
200 208
201 209 $this->steps = apply_filters( 'pll_wizard_steps', $this->steps );
202 210 $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification
203 211
204 - $this->step = $step && array_key_exists( $step, $this->steps ) ? $step : current( array_keys( $this->steps ) );
212 + $this->current_step = $step && array_key_exists( $step, $this->steps ) ? $step : current( array_keys( $this->steps ) );
205 213
206 - $languages = $this->model->get_languages_list();
214 + $has_languages = $this->model->has_languages();
207 215
208 - if ( count( $languages ) === 0 && ! in_array( $this->step, array( 'licenses', 'languages' ) ) ) {
209 - wp_safe_redirect( esc_url_raw( $this->get_step_link( 'languages' ) ) );
216 + if ( ! $has_languages && ! in_array( $this->current_step, array( 'licenses', 'languages' ) ) ) {
217 + wp_safe_redirect( sanitize_url( $this->get_step_link( 'languages' ) ) );
210 218 exit;
211 219 }
212 220
213 - if ( count( $languages ) > 0 && $this->model->get_objects_with_no_lang( 1 ) && ! in_array( $this->step, array( 'licenses', 'languages', 'media', 'untranslated-contents' ) ) ) {
214 - wp_safe_redirect( esc_url_raw( $this->get_step_link( 'untranslated-contents' ) ) );
221 + if ( $has_languages && $this->model->get_objects_with_no_lang( 1 ) && ! in_array( $this->current_step, array( 'licenses', 'languages', 'media', 'untranslated-contents' ) ) ) {
222 + wp_safe_redirect( sanitize_url( $this->get_step_link( 'untranslated-contents' ) ) );
215 223 exit;
216 224 }
217 225
218 226 // Call the handler of the step for going to the next step.
219 227 // Be careful nonce verification with check_admin_referer must be done in each handler.
220 - if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
221 - call_user_func( $this->steps[ $this->step ]['handler'] );
228 + if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->current_step ]['handler'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
229 + call_user_func( $this->steps[ $this->current_step ]['handler'] );
222 230 }
223 231
224 232 $this->display_wizard_page();
225 233 // Ensure nothing is done after including the page.
@@ -270,9 +278,13 @@
270 278 *
271 279 * @return void
272 280 */
273 281 public function display_wizard_page() {
274 - set_current_screen();
282 + set_current_screen( 'pll-wizard' );
283 + do_action( 'admin_enqueue_scripts' );
284 + $steps = $this->steps;
285 + $current_step = $this->current_step;
286 + $styles = $this->styles;
275 287 include __DIR__ . '/view-wizard-page.php';
276 288 }
277 289
278 290 /**
@@ -282,10 +294,10 @@
282 294 *
283 295 * @return void
284 296 */
285 297 public function enqueue_scripts() {
286 - wp_enqueue_style( 'polylang_admin', plugins_url( '/css/build/admin' . $this->get_suffix() . '.css', POLYLANG_BASENAME ), array(), POLYLANG_VERSION );
287 - wp_enqueue_style( 'pll-wizard', plugins_url( '/css/build/wizard' . $this->get_suffix() . '.css', POLYLANG_BASENAME ), array( 'dashicons', 'install', 'common', 'forms' ), POLYLANG_VERSION );
298 + wp_enqueue_style( 'polylang_admin', plugins_url( '/css/build/admin' . $this->get_suffix() . '.css', POLYLANG_ROOT_FILE ), array(), POLYLANG_VERSION );
299 + wp_enqueue_style( 'pll-wizard', plugins_url( '/css/build/wizard' . $this->get_suffix() . '.css', POLYLANG_ROOT_FILE ), array( 'dashicons', 'install', 'common', 'forms' ), POLYLANG_VERSION );
288 300
289 301 $this->styles = array( 'polylang_admin', 'pll-wizard' );
290 302 }
291 303
@@ -311,9 +323,9 @@
311 323 * Empty string on failure.
312 324 */
313 325 public function get_step_link( $step = '' ) {
314 326 if ( ! $step ) {
315 - $step = $this->step;
327 + $step = $this->current_step;
316 328 }
317 329
318 330 $keys = array_keys( $this->steps );
319 331
@@ -336,9 +348,9 @@
336 348 * Empty string on failure.
337 349 */
338 350 public function get_next_step_link( $step = '' ) {
339 351 if ( ! $step ) {
340 - $step = $this->step;
352 + $step = $this->current_step;
341 353 }
342 354
343 355 $keys = array_keys( $this->steps );
344 356 if ( end( $keys ) === $step ) {
@@ -364,12 +376,12 @@
364 376 public function add_step_licenses( $steps ) {
365 377 // Add ajax action on deactivate button in licenses step.
366 378 add_action( 'wp_ajax_pll_deactivate_license', array( $this, 'deactivate_license' ) );
367 379
368 - // Be careful pll_admin script is enqueued here without depedency except jquery because only code useful for deactivate license button is needed.
369 - // To be really loaded the script need to be passed to the $steps['licenses']['scripts'] array below with the same handle than in wp_enqueue_script().
370 - wp_enqueue_script( 'pll_admin', plugins_url( '/js/build/admin' . $this->get_suffix() . '.js', POLYLANG_BASENAME ), array( 'jquery' ), POLYLANG_VERSION, true );
371 - wp_localize_script( 'pll_admin', 'pll_admin', array( 'dismiss_notice' => esc_html__( 'Dismiss this notice.', 'polylang' ) ) );
380 + // Be careful `settings` script is enqueued here without dependency except jquery because only code useful for deactivate license button is needed.
381 + // To be really loaded the script needs to be passed to the `$steps['licenses']['scripts']` array below with the same handle than in `wp_enqueue_script()`.
382 + wp_enqueue_script( 'pll_settings', plugins_url( '/js/build/settings' . $this->get_suffix() . '.js', POLYLANG_ROOT_FILE ), array( 'jquery' ), POLYLANG_VERSION, true );
383 + wp_localize_script( 'pll_settings', 'pll_settings', array( 'dismiss_notice' => esc_html__( 'Dismiss this notice.', 'polylang' ) ) );
372 384
373 385 if ( $this->is_licenses_step_displayable() ) {
374 386 $steps['licenses'] = array(
375 387 'name' => esc_html__( 'Licenses', 'polylang' ),
@@ -374,9 +386,9 @@
374 386 $steps['licenses'] = array(
375 387 'name' => esc_html__( 'Licenses', 'polylang' ),
376 388 'view' => array( $this, 'display_step_licenses' ),
377 389 'handler' => array( $this, 'save_step_licenses' ),
378 - 'scripts' => array( 'pll_admin' ), // Polylang admin script used by deactivate license button.
390 + 'scripts' => array( 'pll_settings' ), // Polylang admin script used by deactivate license button.
379 391 'styles' => array(),
380 392 );
381 393 }
382 394 return $steps;
@@ -412,9 +424,9 @@
412 424 if ( ! empty( $updated_license->license_data ) && false === $updated_license->license_data->success ) {
413 425 // Stay on this step with an error.
414 426 $redirect = add_query_arg(
415 427 array(
416 - 'step' => $this->step,
428 + 'step' => $this->current_step,
417 429 'activate_error' => 'i18n_license_key_error',
418 430 )
419 431 );
420 432 }
@@ -420,9 +432,9 @@
420 432 }
421 433 }
422 434 }
423 435
424 - wp_safe_redirect( esc_url_raw( $redirect ) );
436 + wp_safe_redirect( sanitize_url( $redirect ) );
425 437 exit;
426 438 }
427 439
428 440 /**
@@ -464,14 +476,14 @@
464 476 * @param array $steps List of steps.
465 477 * @return array List of steps updated.
466 478 */
467 479 public function add_step_languages( $steps ) {
468 - wp_deregister_script( 'pll_admin' ); // Deregister after the licenses step enqueue to update jquery-ui-selectmenu dependency.
469 - // The wp-ajax-response and postbox dependencies is useless in wizard steps espacially postbox which triggers a javascript error otherwise.
470 - // To be really loaded the script need to be passed to the $steps['languages']['scripts'] array below with the same handle than in wp_enqueue_script().
471 - wp_enqueue_script( 'pll_admin', plugins_url( '/js/build/admin' . $this->get_suffix() . '.js', POLYLANG_BASENAME ), array( 'jquery', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true );
472 - wp_localize_script( 'pll_admin', 'pll_admin', array( 'dismiss_notice' => esc_html__( 'Dismiss this notice.', 'polylang' ) ) );
473 - wp_register_script( 'pll-wizard-languages', plugins_url( '/js/build/languages-step' . $this->get_suffix() . '.js', POLYLANG_BASENAME ), array( 'jquery', 'jquery-ui-dialog' ), POLYLANG_VERSION, true );
480 + wp_deregister_script( 'pll_settings' ); // Deregister after the licenses step enqueue to update jquery-ui-selectmenu dependency.
481 + // The wp-ajax-response and postbox dependencies is useless in wizard steps especially postbox which triggers a javascript error otherwise.
482 + // To be really loaded the script needs to be passed to the `$steps['languages']['scripts']` array below with the same handle than in `wp_enqueue_script()`.
483 + wp_enqueue_script( 'pll_settings', plugins_url( '/js/build/settings' . $this->get_suffix() . '.js', POLYLANG_ROOT_FILE ), array( 'jquery', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true );
484 + wp_localize_script( 'pll_settings', 'pll_settings', array( 'dismiss_notice' => esc_html__( 'Dismiss this notice.', 'polylang' ) ) );
485 + wp_register_script( 'pll-wizard-languages', plugins_url( '/js/build/languages-step' . $this->get_suffix() . '.js', POLYLANG_ROOT_FILE ), array( 'jquery', 'jquery-ui-dialog' ), POLYLANG_VERSION, true );
474 486 wp_localize_script(
475 487 'pll-wizard-languages',
476 488 'pll_wizard_params',
477 489 array(
@@ -492,14 +504,14 @@
492 504 'i18n_remove_language_icon' => esc_html__( 'Remove this language', 'polylang' ),
493 505 )
494 506 );
495 507 wp_enqueue_script( 'pll-wizard-languages' );
496 - wp_enqueue_style( 'pll-wizard-selectmenu', plugins_url( '/css/build/selectmenu' . $this->get_suffix() . '.css', POLYLANG_BASENAME ), array( 'dashicons', 'install', 'common', 'wp-jquery-ui-dialog' ), POLYLANG_VERSION );
508 + wp_enqueue_style( 'pll-wizard-selectmenu', plugins_url( '/css/build/selectmenu' . $this->get_suffix() . '.css', POLYLANG_ROOT_FILE ), array( 'dashicons', 'install', 'common', 'wp-jquery-ui-dialog' ), POLYLANG_VERSION );
497 509 $steps['languages'] = array(
498 510 'name' => esc_html__( 'Languages', 'polylang' ),
499 511 'view' => array( $this, 'display_step_languages' ),
500 512 'handler' => array( $this, 'save_step_languages' ),
501 - 'scripts' => array( 'pll-wizard-languages', 'pll_admin' ),
513 + 'scripts' => array( 'pll-wizard-languages', 'pll_settings' ),
502 514 'styles' => array( 'pll-wizard-selectmenu' ),
503 515 );
504 516 return $steps;
505 517 }
@@ -511,8 +523,9 @@
511 523 *
512 524 * @return void
513 525 */
514 526 public function display_step_languages() {
527 + $model = $this->model;
515 528 include __DIR__ . '/view-wizard-step-languages.php';
516 529 }
517 530
518 531 /**
@@ -524,22 +537,20 @@
524 537 */
525 538 public function save_step_languages() {
526 539 check_admin_referer( 'pll-wizard', '_pll_nonce' );
527 540
528 - $existing_languages = $this->model->get_languages_list();
529 -
530 - $all_languages = include POLYLANG_DIR . '/settings/languages.php';
531 - $languages = isset( $_POST['languages'] ) && is_array( $_POST['languages'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['languages'] ) ) : false;
541 + $all_languages = include POLYLANG_DIR . '/settings/languages.php';
542 + $languages = isset( $_POST['languages'] ) && is_array( $_POST['languages'] ) ? array_map( 'sanitize_locale_name', $_POST['languages'] ) : false;
532 543 $saved_languages = array();
533 544
534 545 // If there is no language added or defined.
535 - if ( empty( $languages ) && empty( $existing_languages ) ) {
546 + if ( empty( $languages ) && ! $this->model->has_languages() ) {
536 547 // Stay on this step with an error.
537 548 wp_safe_redirect(
538 - esc_url_raw(
549 + sanitize_url(
539 550 add_query_arg(
540 551 array(
541 - 'step' => $this->step,
552 + 'step' => $this->current_step,
542 553 'activate_error' => 'i18n_no_language_added',
543 554 )
544 555 )
545 556 )
@@ -571,12 +582,12 @@
571 582 if ( $language_added instanceof WP_Error ) {
572 583 // Stay on this step with an error.
573 584 $error_keys = array_keys( $language_added->errors );
574 585 wp_safe_redirect(
575 - esc_url_raw(
586 + sanitize_url(
576 587 add_query_arg(
577 588 array(
578 - 'step' => $this->step,
589 + 'step' => $this->current_step,
579 590 'activate_error' => 'i18n_' . reset( $error_keys ),
580 591 )
581 592 )
582 593 )
@@ -588,9 +599,9 @@
588 599 wp_download_language_pack( $locale );
589 600 }
590 601 }
591 602 }
592 - wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
603 + wp_safe_redirect( sanitize_url( $this->get_next_step_link() ) );
593 604 exit;
594 605 }
595 606
596 607 /**
@@ -623,8 +634,9 @@
623 634 *
624 635 * @return void
625 636 */
626 637 public function display_step_media() {
638 + $options = $this->options;
627 639 include __DIR__ . '/view-wizard-step-media.php';
628 640 }
629 641
630 642 /**
@@ -642,9 +654,9 @@
642 654 $this->options['media_support'] = $media_support;
643 655
644 656 update_option( 'polylang', $this->options );
645 657
646 - wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
658 + wp_safe_redirect( sanitize_url( $this->get_next_step_link() ) );
647 659 exit;
648 660 }
649 661
650 662 /**
@@ -655,19 +667,19 @@
655 667 * @param array $steps List of steps.
656 668 * @return array List of steps updated.
657 669 */
658 670 public function add_step_untranslated_contents( $steps ) {
659 - if ( ! $this->model->get_languages_list() || $this->model->get_objects_with_no_lang( 1 ) ) {
660 - // Even if pll_admin is already enqueued with the same dependencies by the languages step, it is interesting to keep that it's also useful for the untranslated-contents step.
661 - // To be really loaded the script need to be passed to the $steps['untranslated-contents']['scripts'] array below with the same handle than in wp_enqueue_script().
662 - wp_enqueue_script( 'pll_admin', plugins_url( '/js/build/admin' . $this->get_suffix() . '.js', POLYLANG_BASENAME ), array( 'jquery', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true );
663 - wp_localize_script( 'pll_admin', 'pll_admin', array( 'dismiss_notice' => esc_html__( 'Dismiss this notice.', 'polylang' ) ) );
664 - wp_enqueue_style( 'pll-wizard-selectmenu', plugins_url( '/css/build/selectmenu' . $this->get_suffix() . '.css', POLYLANG_BASENAME ), array( 'dashicons', 'install', 'common' ), POLYLANG_VERSION );
671 + if ( ! $this->model->has_languages() || $this->model->get_objects_with_no_lang( 1 ) ) {
672 + // Even if `pll_settings` is already enqueued with the same dependencies by the languages step, it is interesting to keep that it's also useful for the untranslated-contents step.
673 + // To be really loaded the script needs to be passed to the `$steps['untranslated-contents']['scripts']` array below with the same handle than in `wp_enqueue_script()`.
674 + wp_enqueue_script( 'pll_settings', plugins_url( '/js/build/settings' . $this->get_suffix() . '.js', POLYLANG_ROOT_FILE ), array( 'jquery', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true );
675 + wp_localize_script( 'pll_settings', 'pll_settings', array( 'dismiss_notice' => esc_html__( 'Dismiss this notice.', 'polylang' ) ) );
676 + wp_enqueue_style( 'pll-wizard-selectmenu', plugins_url( '/css/build/selectmenu' . $this->get_suffix() . '.css', POLYLANG_ROOT_FILE ), array( 'dashicons', 'install', 'common' ), POLYLANG_VERSION );
665 677 $steps['untranslated-contents'] = array(
666 678 'name' => esc_html__( 'Content', 'polylang' ),
667 679 'view' => array( $this, 'display_step_untranslated_contents' ),
668 680 'handler' => array( $this, 'save_step_untranslated_contents' ),
669 - 'scripts' => array( 'pll_admin' ),
681 + 'scripts' => array( 'pll_settings' ),
670 682 'styles' => array( 'pll-wizard-selectmenu' ),
671 683 );
672 684 }
673 685 return $steps;
@@ -680,8 +692,9 @@
680 692 *
681 693 * @return void
682 694 */
683 695 public function display_step_untranslated_contents() {
696 + $model = $this->model;
684 697 include __DIR__ . '/view-wizard-step-untranslated-contents.php';
685 698 }
686 699
687 700 /**
@@ -693,9 +706,9 @@
693 706 */
694 707 public function save_step_untranslated_contents() {
695 708 check_admin_referer( 'pll-wizard', '_pll_nonce' );
696 709
697 - $lang = isset( $_POST['language'] ) ? sanitize_text_field( wp_unslash( $_POST['language'] ) ) : false;
710 + $lang = ! empty( $_POST['language'] ) && is_string( $_POST['language'] ) ? sanitize_locale_name( $_POST['language'] ) : false;
698 711
699 712 if ( empty( $lang ) ) {
700 713 $lang = $this->options['default_lang'];
701 714 }
@@ -701,18 +714,13 @@
701 714 }
702 715
703 716 $language = $this->model->get_language( $lang );
704 717
705 - while ( $nolang = $this->model->get_objects_with_no_lang( 1000 ) ) {
706 - if ( ! empty( $nolang['posts'] ) ) {
707 - $this->model->set_language_in_mass( 'post', $nolang['posts'], $language->slug );
708 - }
709 - if ( ! empty( $nolang['terms'] ) ) {
710 - $this->model->set_language_in_mass( 'term', $nolang['terms'], $language->slug );
711 - }
718 + if ( $language instanceof PLL_Language ) {
719 + $this->model->set_language_in_mass( $language );
712 720 }
713 721
714 - wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
722 + wp_safe_redirect( sanitize_url( $this->get_next_step_link() ) );
715 723 exit;
716 724 }
717 725
718 726 /**
@@ -748,8 +756,26 @@
748 756 *
749 757 * @return void
750 758 */
751 759 public function display_step_home_page() {
760 + $model = $this->model;
761 + $languages = $model->languages->get_list();
762 + $home_page_id = get_option( 'page_on_front' );
763 + $home_page_id = is_numeric( $home_page_id ) ? (int) $home_page_id : 0;
764 + $translations = $model->post->get_translations( $home_page_id );
765 + $home_page = $home_page_id > 0 ? get_post( $home_page_id ) : null;
766 + $home_page_language = $model->post->get_language( $home_page_id );
767 + $untranslated_languages = array();
768 +
769 + if ( empty( $home_page ) ) {
770 + return;
771 + }
772 +
773 + foreach ( $languages as $language ) {
774 + if ( ! $model->post->get( $home_page_id, $language ) ) {
775 + $untranslated_languages[] = $language;
776 + }
777 + }
752 778 include __DIR__ . '/view-wizard-step-home-page.php';
753 779 }
754 780
755 781 /**
@@ -761,11 +787,9 @@
761 787 */
762 788 public function save_step_home_page() {
763 789 check_admin_referer( 'pll-wizard', '_pll_nonce' );
764 790
765 - $languages = $this->model->get_languages_list();
766 -
767 - $default_language = count( $languages ) > 0 ? $this->options['default_lang'] : null;
791 + $default_language = $this->model->has_languages() ? $this->options['default_lang'] : null;
768 792 $home_page = isset( $_POST['home_page'] ) ? sanitize_key( $_POST['home_page'] ) : false;
769 793 $home_page_title = isset( $_POST['home_page_title'] ) ? sanitize_text_field( wp_unslash( $_POST['home_page_title'] ) ) : esc_html__( 'Homepage', 'polylang' );
770 794 $home_page_language = isset( $_POST['home_page_language'] ) ? sanitize_key( $_POST['home_page_language'] ) : false;
771 795
@@ -781,9 +805,9 @@
781 805 );
782 806
783 807 $this->model->clean_languages_cache();
784 808
785 - wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
809 + wp_safe_redirect( sanitize_url( $this->get_next_step_link() ) );
786 810 exit;
787 811 }
788 812
789 813 /**
@@ -857,8 +881,8 @@
857 881 */
858 882 public function save_step_last() {
859 883 check_admin_referer( 'pll-wizard', '_pll_nonce' );
860 884
861 - wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
885 + wp_safe_redirect( sanitize_url( $this->get_next_step_link() ) );
862 886 exit;
863 887 }
864 888 }