| @@ -4,13 +4,28 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package Polylang |
| 6 | 6 | * |
| 7 | 7 | * @since 2.7 |
| 8 | + * | |
| 9 | + * @var array[] $steps { | |
| 10 | + * List of steps. | |
| 11 | + * | |
| 12 | + * @type array { | |
| 13 | + * List of step properties. | |
| 14 | + * | |
| 15 | + * @type string $name I18n string which names the step. | |
| 16 | + * @type callable $view The callback function use to display the step content. | |
| 17 | + * @type callable $handler The callback function use to process the step after it is submitted. | |
| 18 | + * @type array $scripts List of script handles needed by the step. | |
| 19 | + * @type array $styles The list of style handles needed by the step. | |
| 20 | + * } | |
| 21 | + * } | |
| 22 | + * @var string $current_step Current step. | |
| 23 | + * @var string[] $styles List of wizard page styles. | |
| 8 | 24 | */ |
| 9 | 25 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 11 | - exit; // Don't access directly. | |
| 12 | -}; | |
| 26 | +defined( 'ABSPATH' ) || exit; | |
| 27 | + | |
| 13 | 28 | $admin_body_class = array( 'pll-wizard', 'wp-core-ui' ); |
| 14 | 29 | if ( is_rtl() ) { |
| 15 | 30 | $admin_body_class[] = 'rtl'; |
| 16 | 31 | } |
| @@ -28,14 +43,13 @@ | ||
| 28 | 43 | esc_html( POLYLANG ) |
| 29 | 44 | ); |
| 30 | 45 | ?> |
| 31 | 46 | </title> |
| 32 | - <script type="text/javascript"> | |
| 47 | + <script> | |
| 33 | 48 | var ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ); ?>'; |
| 34 | 49 | </script> |
| 35 | - <?php do_action( 'admin_enqueue_scripts' ); ?> | |
| 36 | - <?php wp_print_scripts( $this->steps[ $this->step ]['scripts'] ); ?> | |
| 37 | - <?php wp_print_styles( array_merge( $this->styles, $this->steps[ $this->step ]['styles'] ) ); ?> | |
| 50 | + <?php wp_print_scripts( $steps[ $current_step ]['scripts'] ); ?> | |
| 51 | + <?php wp_print_styles( array_merge( $styles, $steps[ $current_step ]['styles'] ) ); ?> | |
| 38 | 52 | <?php do_action( 'admin_head' ); ?> |
| 39 | 53 | </head> |
| 40 | 54 | <body class="<?php echo join( ' ', array_map( 'sanitize_key', $admin_body_class ) ); ?>"> |
| 41 | 55 | <h1 id="pll-logo"> |
| @@ -45,12 +59,12 @@ | ||
| 45 | 59 | </a> |
| 46 | 60 | </h1> |
| 47 | 61 | <ol class="pll-wizard-steps"> |
| 48 | 62 | <?php |
| 49 | - foreach ( $this->steps as $step_key => $step ) { | |
| 50 | - $is_completed = array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ); | |
| 63 | + foreach ( $steps as $step_key => $step ) { | |
| 64 | + $is_completed = array_search( $current_step, array_keys( $steps ), true ) > array_search( $step_key, array_keys( $steps ), true ); | |
| 51 | 65 | |
| 52 | - if ( $step_key === $this->step ) { | |
| 66 | + if ( $step_key === $current_step ) { | |
| 53 | 67 | ?> |
| 54 | 68 | <li class="active"><?php echo esc_html( $step['name'] ); ?></li> |
| 55 | 69 | <?php |
| 56 | 70 | } elseif ( $is_completed ) { |
| @@ -71,17 +85,17 @@ | ||
| 71 | 85 | } |
| 72 | 86 | ?> |
| 73 | 87 | </ol> |
| 74 | 88 | <div class="pll-wizard-content"> |
| 75 | - <form method="post" class="<?php echo esc_attr( "{$this->step}-step" ); ?>"> | |
| 89 | + <form method="post" class="<?php echo esc_attr( "{$current_step}-step" ); ?>"> | |
| 76 | 90 | <?php |
| 77 | 91 | wp_nonce_field( 'pll-wizard', '_pll_nonce' ); |
| 78 | 92 | |
| 79 | - if ( ! empty( $this->steps[ $this->step ]['view'] ) ) { | |
| 80 | - call_user_func( $this->steps[ $this->step ]['view'], $this ); | |
| 93 | + if ( ! empty( $steps[ $current_step ]['view'] ) ) { | |
| 94 | + call_user_func( $steps[ $current_step ]['view'] ); | |
| 81 | 95 | } |
| 82 | 96 | ?> |
| 83 | - <?php if ( 'last' !== $this->step ) : ?> | |
| 97 | + <?php if ( 'last' !== $current_step ) : ?> | |
| 84 | 98 | <p class="pll-wizard-actions step"> |
| 85 | 99 | <button |
| 86 | 100 | type="submit" |
| 87 | 101 | class="button-primary button button-large button-next" |
| @@ -94,9 +108,9 @@ | ||
| 94 | 108 | <?php endif; ?> |
| 95 | 109 | </form> |
| 96 | 110 | </div> |
| 97 | 111 | <div class="pll-wizard-footer"> |
| 98 | - <?php if ( 'last' !== $this->step ) : ?> | |
| 112 | + <?php if ( 'last' !== $current_step ) : ?> | |
| 99 | 113 | <a |
| 100 | 114 | class="pll-wizard-footer-links" |
| 101 | 115 | href="<?php echo esc_url( admin_url() ); ?>" |
| 102 | 116 | > |