PluginProbe
Polylang / 3.1
Polylang v3.1
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 +143 -67 2.83.1 View file →
@@ -9,33 +9,46 @@
9 9 * @since 2.7
10 10 */
11 11 class PLL_Wizard {
12 12 /**
13 - * Reference to PLL_Model object
13 + * Reference to the model object
14 14 *
15 - * @var object $model
15 + * @var PLL_Admin_Model
16 16 */
17 17 protected $model;
18 18
19 19 /**
20 - * Reference to Polylang options array
20 + * Reference to the Polylang options array.
21 21 *
22 - * @var array $options
22 + * @var array
23 23 */
24 24 protected $options;
25 25
26 26 /**
27 - * List of steps
27 + * List of steps.
28 28 *
29 - * @var array $steps
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.
35 + * }
30 36 */
31 37 protected $steps = array();
32 38
33 39 /**
34 - * List of WordPress CSS file handles
40 + * The current step.
35 41 *
36 - * @var array $styles
42 + * @var string
37 43 */
44 + protected $step;
45 +
46 + /**
47 + * List of WordPress CSS file handles.
48 + *
49 + * @var string[]
50 + */
38 51 protected $styles = array();
39 52
40 53 /**
41 54 * Constructor
@@ -66,10 +79,12 @@
66 79
67 80 /**
68 81 * Save an activation transient when Polylang is activating to redirect to the wizard
69 82 *
83 + * @since 2.7
84 + *
70 85 * @param bool $network_wide if activated for all sites in the network.
71 - * @since 2.7
86 + * @return void
72 87 */
73 88 public static function start_wizard( $network_wide ) {
74 89 $options = get_option( 'polylang' );
75 90
@@ -82,8 +97,10 @@
82 97 /**
83 98 * Redirect to the wizard depending on the context
84 99 *
85 100 * @since 2.7
101 + *
102 + * @return void
86 103 */
87 104 public function redirect_to_wizard() {
88 105 if ( get_transient( 'pll_activation_redirect' ) ) {
89 106 $do_redirect = true;
@@ -110,23 +127,25 @@
110 127
111 128 /**
112 129 * Add an admin Polylang submenu to access the wizard
113 130 *
114 - * @param array $tabs Submenus list.
115 - * @return array Submenus list updated.
116 131 * @since 2.7
132 + *
133 + * @param string[] $tabs Submenus list.
134 + * @return string[] Submenus list updated.
117 135 */
118 136 public function settings_tabs( $tabs ) {
119 - $tabs['wizard'] = __( 'Setup', 'polylang' );
137 + $tabs['wizard'] = esc_html__( 'Setup', 'polylang' );
120 138 return $tabs;
121 139 }
122 140
123 141 /**
124 - * Return if the media step is displayable
142 + * Returns true if the media step is displayable, false otherwise.
125 143 *
126 - * @param array $languages List of language objects.
144 + * @since 2.7
145 + *
146 + * @param PLL_Language[] $languages List of language objects.
127 147 * @return bool
128 - * @since 2.7
129 148 */
130 149 public function is_media_step_displayable( $languages ) {
131 150 $media = array();
132 151 // If there is no language or only one the media step is displayable.
@@ -147,10 +166,11 @@
147 166
148 167 /**
149 168 * Check if the licenses step is displayable
150 169 *
170 + * @since 2.7
171 + *
151 172 * @return bool
152 - * @since 2.7
153 173 */
154 174 public function is_licenses_step_displayable() {
155 175 $licenses = apply_filters( 'pll_settings_licenses', array() );
156 176 return count( $licenses ) > 0;
@@ -159,8 +179,10 @@
159 179 /**
160 180 * Setup the wizard page
161 181 *
162 182 * @since 2.7
183 + *
184 + * @return void
163 185 */
164 186 public function setup_wizard_page() {
165 187
166 188 PLL_Admin_Notices::add_notice( 'wizard', $this->wizard_notice() );
@@ -206,17 +228,18 @@
206 228
207 229 /**
208 230 * Adds some admin screens where to display the wizard notice
209 231 *
232 + * @since 2.7
233 + *
210 234 * @param bool $can_display_notice Whether the notice can be displayed.
211 235 * @param string $notice The notice name.
212 236 * @return bool
213 - * @since 2.7
214 237 */
215 238 public function can_display_notice( $can_display_notice, $notice ) {
216 239 if ( ! $can_display_notice && 'wizard' === $notice ) {
217 240 $screen = get_current_screen();
218 - $can_display_notice = in_array(
241 + $can_display_notice = ! empty( $screen ) && in_array(
219 242 $screen->base,
220 243 array(
221 244 'edit',
222 245 'upload',
@@ -230,8 +253,10 @@
230 253 /**
231 254 * Return html code of the wizard notice
232 255 *
233 256 * @since 2.7
257 + *
258 + * @return string
234 259 */
235 260 public function wizard_notice() {
236 261 ob_start();
237 262 include __DIR__ . '/html-wizard-notice.php';
@@ -241,8 +266,10 @@
241 266 /**
242 267 * Display the wizard page
243 268 *
244 269 * @since 2.7
270 + *
271 + * @return void
245 272 */
246 273 public function display_wizard_page() {
247 274 set_current_screen();
248 275 include __DIR__ . '/view-wizard-page.php';
@@ -251,12 +278,14 @@
251 278 /**
252 279 * Enqueue scripts and styles for the wizard
253 280 *
254 281 * @since 2.7
282 + *
283 + * @return void
255 284 */
256 285 public function enqueue_scripts() {
257 - wp_enqueue_style( 'polylang_admin', plugins_url( '/css/admin' . $this->get_suffix() . '.css', POLYLANG_FILE ), array(), POLYLANG_VERSION );
258 - wp_enqueue_style( 'pll-wizard', plugins_url( '/modules/wizard/css/wizard' . $this->get_suffix() . '.css', POLYLANG_FILE ), array( 'dashicons', 'install', 'common', 'forms' ), POLYLANG_VERSION );
286 + wp_enqueue_style( 'polylang_admin', plugins_url( '/css/build/admin' . $this->get_suffix() . '.css', POLYLANG_ROOT_FILE ), array(), POLYLANG_VERSION );
287 + wp_enqueue_style( 'pll-wizard', plugins_url( '/css/build/wizard' . $this->get_suffix() . '.css', POLYLANG_ROOT_FILE ), array( 'dashicons', 'install', 'common', 'forms' ), POLYLANG_VERSION );
259 288
260 289 $this->styles = array( 'polylang_admin', 'pll-wizard' );
261 290 }
262 291
@@ -262,11 +291,12 @@
262 291
263 292 /**
264 293 * Get the suffix to enqueue non minified files in a Debug context
265 294 *
295 + * @since 2.7
296 + *
266 297 * @return string Empty when SCRIPT_DEBUG equal to true
267 298 * otherwise .min
268 - * @since 2.7
269 299 */
270 300 public function get_suffix() {
271 301 return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
272 302 }
@@ -273,12 +303,13 @@
273 303
274 304 /**
275 305 * Get the URL for the step's screen.
276 306 *
307 + * @since 2.7
308 + *
277 309 * @param string $step slug (default: current step).
278 310 * @return string URL for the step if it exists.
279 311 * Empty string on failure.
280 - * @since 2.7
281 312 */
282 313 public function get_step_link( $step = '' ) {
283 314 if ( ! $step ) {
284 315 $step = $this->step;
@@ -296,13 +327,14 @@
296 327
297 328 /**
298 329 * Get the URL for the next step's screen.
299 330 *
331 + * @since 2.7
332 + *
300 333 * @param string $step slug (default: current step).
301 334 * @return string URL for next step if a next step exists.
302 335 * Admin URL if it's the last step.
303 336 * Empty string on failure.
304 - * @since 2.7
305 337 */
306 338 public function get_next_step_link( $step = '' ) {
307 339 if ( ! $step ) {
308 340 $step = $this->step;
@@ -323,20 +355,25 @@
323 355
324 356 /**
325 357 * Add licenses step to the wizard
326 358 *
359 + * @since 2.7
360 + *
327 361 * @param array $steps List of steps.
328 362 * @return array List of steps updated.
329 - * @since 2.7
330 363 */
331 364 public function add_step_licenses( $steps ) {
332 365 // Add ajax action on deactivate button in licenses step.
333 366 add_action( 'wp_ajax_pll_deactivate_license', array( $this, 'deactivate_license' ) );
334 367
335 - wp_enqueue_script( 'pll_admin', plugins_url( '/js/admin' . $this->get_suffix() . '.js', POLYLANG_FILE ), array( 'jquery', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true );
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_ROOT_FILE ), array( 'jquery' ), POLYLANG_VERSION, true );
371 + wp_localize_script( 'pll_admin', 'pll_admin', array( 'dismiss_notice' => esc_html__( 'Dismiss this notice.', 'polylang' ) ) );
372 +
336 373 if ( $this->is_licenses_step_displayable() ) {
337 374 $steps['licenses'] = array(
338 - 'name' => __( 'Licenses', 'polylang' ),
375 + 'name' => esc_html__( 'Licenses', 'polylang' ),
339 376 'view' => array( $this, 'display_step_licenses' ),
340 377 'handler' => array( $this, 'save_step_licenses' ),
341 378 'scripts' => array( 'pll_admin' ), // Polylang admin script used by deactivate license button.
342 379 'styles' => array(),
@@ -348,8 +385,10 @@
348 385 /**
349 386 * Display the languages step form
350 387 *
351 388 * @since 2.7
389 + *
390 + * @return void
352 391 */
353 392 public function display_step_licenses() {
354 393 include __DIR__ . '/view-wizard-step-licenses.php';
355 394 }
@@ -357,8 +396,10 @@
357 396 /**
358 397 * Execute the languages step
359 398 *
360 399 * @since 2.7
400 + *
401 + * @return void
361 402 */
362 403 public function save_step_licenses() {
363 404 check_admin_referer( 'pll-wizard', '_pll_nonce' );
364 405
@@ -387,8 +428,10 @@
387 428 /**
388 429 * Ajax method to deactivate a license
389 430 *
390 431 * @since 2.7
432 + *
433 + * @return void
391 434 */
392 435 public function deactivate_license() {
393 436 check_ajax_referer( 'pll-wizard', '_pll_nonce' );
394 437
@@ -415,43 +458,48 @@
415 458
416 459 /**
417 460 * Add languages step to the wizard
418 461 *
462 + * @since 2.7
463 + *
419 464 * @param array $steps List of steps.
420 465 * @return array List of steps updated.
421 - * @since 2.7
422 466 */
423 467 public function add_step_languages( $steps ) {
424 - wp_enqueue_script( 'pll-wizard-language-choice', plugins_url( '/js/admin' . $this->get_suffix() . '.js', POLYLANG_FILE ), array( 'jquery', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true );
425 - wp_register_script( 'pll-wizard-languages', plugins_url( '/modules/wizard/js/languages-step' . $this->get_suffix() . '.js', POLYLANG_FILE ), array( 'jquery', 'jquery-ui-dialog' ), POLYLANG_VERSION, true );
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_ROOT_FILE ), 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_ROOT_FILE ), array( 'jquery', 'jquery-ui-dialog' ), POLYLANG_VERSION, true );
426 474 wp_localize_script(
427 475 'pll-wizard-languages',
428 476 'pll_wizard_params',
429 477 array(
430 - 'i18n_no_language_selected' => __( 'You need to select a language to be added.', 'polylang' ),
431 - 'i18n_language_already_added' => __( 'You already added this language.', 'polylang' ),
432 - 'i18n_no_language_added' => __( 'You need to add at least one language.', 'polylang' ),
433 - 'i18n_add_language_needed' => __( 'You selected a language, however, to be able to continue, you need to add it.', 'polylang' ),
434 - 'i18n_pll_add_language' => __( 'Impossible to add the language.', 'polylang' ),
435 - 'i18n_pll_invalid_locale' => __( 'Enter a valid WordPress locale', 'polylang' ),
436 - 'i18n_pll_invalid_slug' => __( 'The language code contains invalid characters', 'polylang' ),
437 - 'i18n_pll_non_unique_slug' => __( 'The language code must be unique', 'polylang' ),
438 - 'i18n_pll_invalid_name' => __( 'The language must have a name', 'polylang' ),
439 - 'i18n_pll_invalid_flag' => __( 'The flag does not exist', 'polylang' ),
440 - 'i18n_dialog_title' => __( "A language wasn't added.", 'polylang' ),
441 - 'i18n_dialog_yes_button' => __( 'Yes', 'polylang' ),
442 - 'i18n_dialog_no_button' => __( 'No', 'polylang' ),
443 - 'i18n_dialog_ignore_button' => __( 'Ignore', 'polylang' ),
444 - 'i18n_remove_language_icon' => __( 'Remove this language', 'polylang' ),
478 + 'i18n_no_language_selected' => esc_html__( 'You need to select a language to be added.', 'polylang' ),
479 + 'i18n_language_already_added' => esc_html__( 'You already added this language.', 'polylang' ),
480 + 'i18n_no_language_added' => esc_html__( 'You need to add at least one language.', 'polylang' ),
481 + 'i18n_add_language_needed' => esc_html__( 'You selected a language, however, to be able to continue, you need to add it.', 'polylang' ),
482 + 'i18n_pll_add_language' => esc_html__( 'Impossible to add the language.', 'polylang' ),
483 + 'i18n_pll_invalid_locale' => esc_html__( 'Enter a valid WordPress locale', 'polylang' ),
484 + 'i18n_pll_invalid_slug' => esc_html__( 'The language code contains invalid characters', 'polylang' ),
485 + 'i18n_pll_non_unique_slug' => esc_html__( 'The language code must be unique', 'polylang' ),
486 + 'i18n_pll_invalid_name' => esc_html__( 'The language must have a name', 'polylang' ),
487 + 'i18n_pll_invalid_flag' => esc_html__( 'The flag does not exist', 'polylang' ),
488 + 'i18n_dialog_title' => esc_html__( "A language wasn't added.", 'polylang' ),
489 + 'i18n_dialog_yes_button' => esc_html__( 'Yes', 'polylang' ),
490 + 'i18n_dialog_no_button' => esc_html__( 'No', 'polylang' ),
491 + 'i18n_dialog_ignore_button' => esc_html__( 'Ignore', 'polylang' ),
492 + 'i18n_remove_language_icon' => esc_html__( 'Remove this language', 'polylang' ),
445 493 )
446 494 );
447 495 wp_enqueue_script( 'pll-wizard-languages' );
448 - wp_enqueue_style( 'pll-wizard-selectmenu', plugins_url( '/css/selectmenu' . $this->get_suffix() . '.css', POLYLANG_FILE ), array( 'dashicons', 'install', 'common', 'wp-jquery-ui-dialog' ), POLYLANG_VERSION );
496 + 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 );
449 497 $steps['languages'] = array(
450 - 'name' => __( 'Languages', 'polylang' ),
498 + 'name' => esc_html__( 'Languages', 'polylang' ),
451 499 'view' => array( $this, 'display_step_languages' ),
452 500 'handler' => array( $this, 'save_step_languages' ),
453 - 'scripts' => array( 'pll-wizard-languages', 'pll-wizard-language-choice' ),
501 + 'scripts' => array( 'pll-wizard-languages', 'pll_admin' ),
454 502 'styles' => array( 'pll-wizard-selectmenu' ),
455 503 );
456 504 return $steps;
457 505 }
@@ -459,8 +507,10 @@
459 507 /**
460 508 * Display the languages step form
461 509 *
462 510 * @since 2.7
511 + *
512 + * @return void
463 513 */
464 514 public function display_step_languages() {
465 515 include __DIR__ . '/view-wizard-step-languages.php';
466 516 }
@@ -468,8 +518,10 @@
468 518 /**
469 519 * Execute the languages step
470 520 *
471 521 * @since 2.7
522 + *
523 + * @return void
472 524 */
473 525 public function save_step_languages() {
474 526 check_admin_referer( 'pll-wizard', '_pll_nonce' );
475 527
@@ -475,9 +527,9 @@
475 527
476 528 $existing_languages = $this->model->get_languages_list();
477 529
478 530 $all_languages = include POLYLANG_DIR . '/settings/languages.php';
479 - $languages = isset( $_POST['languages'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['languages'] ) ) : false;
531 + $languages = isset( $_POST['languages'] ) && is_array( $_POST['languages'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['languages'] ) ) : false;
480 532 $saved_languages = array();
481 533
482 534 // If there is no language added or defined.
483 535 if ( empty( $languages ) && empty( $existing_languages ) ) {
@@ -530,9 +582,10 @@
530 582 )
531 583 );
532 584 exit;
533 585 }
534 - if ( 'en_US' !== $locale ) {
586 +
587 + if ( 'en_US' !== $locale && current_user_can( 'install_languages' ) ) {
535 588 wp_download_language_pack( $locale );
536 589 }
537 590 }
538 591 }
@@ -540,14 +593,14 @@
540 593 exit;
541 594 }
542 595
543 596 /**
544 - * Add media step to the wizard
545 - * Add media step to the wizard
597 + * Add the media step to the wizard.
546 598 *
599 + * @since 2.7
600 + *
547 601 * @param array $steps List of steps.
548 602 * @return array List of steps updated.
549 - * @since 2.7
550 603 */
551 604 public function add_step_media( $steps ) {
552 605 $languages = $this->model->get_languages_list();
553 606
@@ -552,9 +605,9 @@
552 605 $languages = $this->model->get_languages_list();
553 606
554 607 if ( $this->is_media_step_displayable( $languages ) ) {
555 608 $steps['media'] = array(
556 - 'name' => __( 'Media', 'polylang' ),
609 + 'name' => esc_html__( 'Media', 'polylang' ),
557 610 'view' => array( $this, 'display_step_media' ),
558 611 'handler' => array( $this, 'save_step_media' ),
559 612 'scripts' => array(),
560 613 'styles' => array(),
@@ -566,8 +619,10 @@
566 619 /**
567 620 * Display the media step form
568 621 *
569 622 * @since 2.7
623 + *
624 + * @return void
570 625 */
571 626 public function display_step_media() {
572 627 include __DIR__ . '/view-wizard-step-media.php';
573 628 }
@@ -575,8 +630,10 @@
575 630 /**
576 631 * Execute the media step
577 632 *
578 633 * @since 2.7
634 + *
635 + * @return void
579 636 */
580 637 public function save_step_media() {
581 638 check_admin_referer( 'pll-wizard', '_pll_nonce' );
582 639
@@ -592,21 +649,25 @@
592 649
593 650 /**
594 651 * Add untranslated contents step to the wizard
595 652 *
653 + * @since 2.7
654 + *
596 655 * @param array $steps List of steps.
597 656 * @return array List of steps updated.
598 - * @since 2.7
599 657 */
600 658 public function add_step_untranslated_contents( $steps ) {
601 659 if ( ! $this->model->get_languages_list() || $this->model->get_objects_with_no_lang( 1 ) ) {
602 - wp_enqueue_script( 'pll-wizard-language-choice', plugins_url( '/js/admin' . $this->get_suffix() . '.js', POLYLANG_FILE ), array( 'jquery', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true );
603 - wp_enqueue_style( 'pll-wizard-selectmenu', plugins_url( '/css/selectmenu' . $this->get_suffix() . '.css', POLYLANG_FILE ), array( 'dashicons', 'install', 'common' ), POLYLANG_VERSION );
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_ROOT_FILE ), 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_ROOT_FILE ), array( 'dashicons', 'install', 'common' ), POLYLANG_VERSION );
604 665 $steps['untranslated-contents'] = array(
605 - 'name' => __( 'Content', 'polylang' ),
666 + 'name' => esc_html__( 'Content', 'polylang' ),
606 667 'view' => array( $this, 'display_step_untranslated_contents' ),
607 668 'handler' => array( $this, 'save_step_untranslated_contents' ),
608 - 'scripts' => array( 'pll-wizard-language-choice' ),
669 + 'scripts' => array( 'pll_admin' ),
609 670 'styles' => array( 'pll-wizard-selectmenu' ),
610 671 );
611 672 }
612 673 return $steps;
@@ -615,8 +676,10 @@
615 676 /**
616 677 * Display the untranslated contents step form
617 678 *
618 679 * @since 2.7
680 + *
681 + * @return void
619 682 */
620 683 public function display_step_untranslated_contents() {
621 684 include __DIR__ . '/view-wizard-step-untranslated-contents.php';
622 685 }
@@ -624,8 +687,10 @@
624 687 /**
625 688 * Execute the untranslated contents step
626 689 *
627 690 * @since 2.7
691 + *
692 + * @return void
628 693 */
629 694 public function save_step_untranslated_contents() {
630 695 check_admin_referer( 'pll-wizard', '_pll_nonce' );
631 696
@@ -652,11 +717,12 @@
652 717
653 718 /**
654 719 * Add home page step to the wizard
655 720 *
721 + * @since 2.7
722 + *
656 723 * @param array $steps List of steps.
657 724 * @return array List of steps updated.
658 - * @since 2.7
659 725 */
660 726 public function add_step_home_page( $steps ) {
661 727 $languages = $this->model->get_languages_list();
662 728 $home_page_id = get_option( 'page_on_front' );
@@ -664,9 +730,9 @@
664 730 $translations = $this->model->post->get_translations( $home_page_id );
665 731
666 732 if ( $home_page_id > 0 && ( ! $languages || count( $languages ) === 1 || count( $translations ) !== count( $languages ) ) ) {
667 733 $steps['home-page'] = array(
668 - 'name' => __( 'Homepage', 'polylang' ),
734 + 'name' => esc_html__( 'Homepage', 'polylang' ),
669 735 'view' => array( $this, 'display_step_home_page' ),
670 736 'handler' => array( $this, 'save_step_home_page' ),
671 737 'scripts' => array(),
672 738 'styles' => array(),
@@ -678,8 +744,10 @@
678 744 /**
679 745 * Display the home page step form
680 746 *
681 747 * @since 2.7
748 + *
749 + * @return void
682 750 */
683 751 public function display_step_home_page() {
684 752 include __DIR__ . '/view-wizard-step-home-page.php';
685 753 }
@@ -687,8 +755,10 @@
687 755 /**
688 756 * Execute the home page step
689 757 *
690 758 * @since 2.7
759 + *
760 + * @return void
691 761 */
692 762 public function save_step_home_page() {
693 763 check_admin_referer( 'pll-wizard', '_pll_nonce' );
694 764
@@ -720,13 +790,14 @@
720 790 * Create home page translations for each language defined.
721 791 *
722 792 * @since 2.7
723 793 *
724 - * @param string $default_language slug of the default language; null if no default language is defined.
725 - * @param int $home_page post_id of the home page if it's defined, false otherwise.
726 - * @param string $home_page_title home page title if it's defined, 'Homepage' otherwise.
727 - * @param string $home_page_language slug of the home page if it's defined, false otherwise.
728 - * @param array $untranslated_languages array of languages which needs to have a home page translated.
794 + * @param string $default_language Slug of the default language; null if no default language is defined.
795 + * @param int $home_page Post ID of the home page if it's defined, false otherwise.
796 + * @param string $home_page_title Home page title if it's defined, 'Homepage' otherwise.
797 + * @param string $home_page_language Slug of the home page if it's defined, false otherwise.
798 + * @param string[] $untranslated_languages Array of languages which needs to have a home page translated.
799 + * @return void
729 800 */
730 801 public function create_home_page_translations( $default_language, $home_page, $home_page_title, $home_page_language, $untranslated_languages ) {
731 802 $translations = $this->model->post->get_translations( $home_page );
732 803
@@ -747,15 +818,16 @@
747 818
748 819 /**
749 820 * Add last step to the wizard
750 821 *
822 + * @since 2.7
823 + *
751 824 * @param array $steps List of steps.
752 825 * @return array List of steps updated.
753 - * @since 2.7
754 826 */
755 827 public function add_step_last( $steps ) {
756 828 $steps['last'] = array(
757 - 'name' => __( 'Ready!', 'polylang' ),
829 + 'name' => esc_html__( 'Ready!', 'polylang' ),
758 830 'view' => array( $this, 'display_step_last' ),
759 831 'handler' => array( $this, 'save_step_last' ),
760 832 'scripts' => array(),
761 833 'styles' => array(),
@@ -766,8 +838,10 @@
766 838 /**
767 839 * Display the last step form
768 840 *
769 841 * @since 2.7
842 + *
843 + * @return void
770 844 */
771 845 public function display_step_last() {
772 846 // We ran the wizard once. So we can dismiss its notice.
773 847 PLL_Admin_Notices::dismiss( 'wizard' );
@@ -777,8 +851,10 @@
777 851 /**
778 852 * Execute the last step
779 853 *
780 854 * @since 2.7
855 + *
856 + * @return void
781 857 */
782 858 public function save_step_last() {
783 859 check_admin_referer( 'pll-wizard', '_pll_nonce' );
784 860