| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @version 1.0 |
| 4 | 4 | * @package Tour |
| @@ -190,15 +190,29 @@ | ||
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
| 194 | -/** | |
| 195 | - * Just for loading CSS and JavaScript files and define Ajax hook | |
| 196 | - */ | |
| 197 | -if ( | |
| 198 | - ( ! wpbc_is_this_demo() ) && | |
| 199 | - ( wpbc_setup_wizard_page__is_need_start() ) && | |
| 200 | - ( wpbc_is_user_can_access_wizard_page() ) | |
| 201 | -) { | |
| 202 | - $wpbc_js_css_loading = new WPBC_Tour_01; | |
| 203 | - $wpbc_js_css_loading->init_load_css_js(); | |
| 204 | -} | |
| 194 | +/** | |
| 195 | + * Initialize Setup Wizard tour assets after WordPress bootstrap is ready. | |
| 196 | + * | |
| 197 | + * The tour eligibility check reads Setup Wizard route state and, in MultiUser, | |
| 198 | + * the current WordPress user. Running it while this file is included is too | |
| 199 | + * early because pluggable current-user functions and just-in-time translation | |
| 200 | + * loading are not guaranteed until `init`. | |
| 201 | + * | |
| 202 | + * @return void | |
| 203 | + */ | |
| 204 | +function wpbc_tour_maybe_initialize_setup_wizard_tour() { | |
| 205 | + | |
| 206 | + if ( | |
| 207 | + ! is_admin() | |
| 208 | + || wpbc_is_this_demo() | |
| 209 | + || ! wpbc_setup_wizard_page__is_need_start() | |
| 210 | + || ! wpbc_is_user_can_access_wizard_page() | |
| 211 | + ) { | |
| 212 | + return; | |
| 213 | + } | |
| 214 | + | |
| 215 | + $wpbc_js_css_loading = new WPBC_Tour_01(); | |
| 216 | + $wpbc_js_css_loading->init_load_css_js(); | |
| 217 | +} | |
| 218 | +add_action( 'init', 'wpbc_tour_maybe_initialize_setup_wizard_tour', 20 ); | |