Merge pull request woocommerce/woocommerce-admin#2676 from woocommerce/fix/determine-page-too-early

Fix missing nav on connected admin pages.
This commit is contained in:
Jeff Stieler 2019-07-22 09:32:16 -06:00 committed by GitHub
commit 6c556d6479
2 changed files with 7 additions and 1 deletions

View File

@ -50,7 +50,7 @@ class WC_Admin_Onboarding {
add_action( 'woocommerce_theme_installed', array( $this, 'delete_themes_transient' ) );
add_action( 'after_switch_theme', array( $this, 'delete_themes_transient' ) );
add_action( 'current_screen', array( $this, 'update_help_tab' ), 60 );
add_action( 'admin_init', array( $this, 'reset_onboarding' ) );
add_action( 'current_screen', array( $this, 'reset_onboarding' ) );
add_filter( 'woocommerce_admin_is_loading', array( $this, 'is_loading' ) );
add_filter( 'woocommerce_rest_prepare_themes', array( $this, 'add_uploaded_theme_data' ) );
}

View File

@ -187,6 +187,12 @@ class WC_Admin_Page_Controller {
* @return array|boolean Current page or false if not registered with this controller.
*/
public function get_current_page() {
// If 'current_screen' hasn't fired yet, the current page calculation
// will fail which causes `false` to be returned for all subsquent calls.
if ( ! did_action( 'current_screen' ) ) {
_doing_it_wrong( __FUNCTION__, esc_html__( 'Current page retreival should be called on or after the `current_screen` hook.', 'woocommerce-admin' ) );
}
if ( is_null( $this->current_page ) ) {
$this->determine_current_page();
}