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