Skip to content

Commit

Permalink
fix admin menu
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Jul 18, 2023
1 parent bdf1213 commit 537b897
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wp-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- name: Build
run: |
yarn install
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
composer install --no-dev
yarn build:js
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wporg-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- name: Build
run: |
yarn install
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
composer install --no-dev
yarn build:js
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ assets/css/*
assets/asset-manifest.json
assets/static
assets/report.html
.yarn.lock
yarn.lock
.yarn/install-state.gz
.yarn/cache
hookdocs
4 changes: 1 addition & 3 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ private function init(): void {

/**
* Fires before the administration menu loads in the admin.
*
* @param string $context Empty context.
*/
public function admin_menu( $context ): void {
public function admin_menu(): void {
$menu = new Admin\Menu();
$this->menu_ids = array(
'toplevel' => $menu->toplevel_screen_id,
Expand Down
27 changes: 13 additions & 14 deletions includes/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __construct() {

// Init hooks
add_action( 'init', array( $this, 'init' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'rest_api_init', array( $this, 'rest_api_init' ), 20 );
add_filter( 'query_vars', array( $this, 'query_vars' ) );

Expand Down Expand Up @@ -72,23 +71,23 @@ public function init(): void {
new Form_Handler();
}

/**
* NOTE: admin_menu runs before admin_init, so we need to load the Admin class here
*/
if ( is_admin() ) {
if ( defined( '\DOING_AJAX' ) && DOING_AJAX ) {
// AJAX requests
new AJAX();
} else {
// Non-AJAX (Admin) requests
new Admin();
}
}

// load integrations
$this->integrations();
}

/**
*
*/
public function admin_init(): void {
if ( defined( '\DOING_AJAX' ) && DOING_AJAX ) {
// AJAX requests
new AJAX();
} else {
// Non-AJAX (Admin) requests
new Admin();
}
}

/**
* Loads the POS API and duck punches the WC REST API.
*/
Expand Down

0 comments on commit 537b897

Please sign in to comment.