Skip to content

Commit 537b897

Browse files
committed
fix admin menu
1 parent bdf1213 commit 537b897

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

.github/workflows/wp-engine.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
- name: Build
1717
run: |
18-
yarn install
18+
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
1919
composer install --no-dev
2020
yarn build:js
2121

.github/workflows/wporg-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
- name: Build
1818
run: |
19-
yarn install
19+
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
2020
composer install --no-dev
2121
yarn build:js
2222

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ assets/css/*
2323
assets/asset-manifest.json
2424
assets/static
2525
assets/report.html
26-
.yarn.lock
26+
yarn.lock
2727
.yarn/install-state.gz
2828
.yarn/cache
2929
hookdocs

includes/Admin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ private function init(): void {
3838

3939
/**
4040
* Fires before the administration menu loads in the admin.
41-
*
42-
* @param string $context Empty context.
4341
*/
44-
public function admin_menu( $context ): void {
42+
public function admin_menu(): void {
4543
$menu = new Admin\Menu();
4644
$this->menu_ids = array(
4745
'toplevel' => $menu->toplevel_screen_id,

includes/Init.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public function __construct() {
2828

2929
// Init hooks
3030
add_action( 'init', array( $this, 'init' ) );
31-
add_action( 'admin_init', array( $this, 'admin_init' ) );
3231
add_action( 'rest_api_init', array( $this, 'rest_api_init' ), 20 );
3332
add_filter( 'query_vars', array( $this, 'query_vars' ) );
3433

@@ -72,23 +71,23 @@ public function init(): void {
7271
new Form_Handler();
7372
}
7473

74+
/**
75+
* NOTE: admin_menu runs before admin_init, so we need to load the Admin class here
76+
*/
77+
if ( is_admin() ) {
78+
if ( defined( '\DOING_AJAX' ) && DOING_AJAX ) {
79+
// AJAX requests
80+
new AJAX();
81+
} else {
82+
// Non-AJAX (Admin) requests
83+
new Admin();
84+
}
85+
}
86+
7587
// load integrations
7688
$this->integrations();
7789
}
7890

79-
/**
80-
*
81-
*/
82-
public function admin_init(): void {
83-
if ( defined( '\DOING_AJAX' ) && DOING_AJAX ) {
84-
// AJAX requests
85-
new AJAX();
86-
} else {
87-
// Non-AJAX (Admin) requests
88-
new Admin();
89-
}
90-
}
91-
9291
/**
9392
* Loads the POS API and duck punches the WC REST API.
9493
*/

0 commit comments

Comments
 (0)