Skip to content

Commit 3532e0f

Browse files
Add autoloading via composer PSR-4
1 parent 4fda85e commit 3532e0f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.github/workflows/build-release-zip.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- name: Build plugin
3939
run: |
4040
npm run build
41+
composer dump-autoload
4142
4243
- name: Install SVN
4344
run: |

composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818
"10up/phpcs-composer": "^3.0",
1919
"sirbrillig/phpcs-changed": "^2.11"
2020
},
21+
"autoload": {
22+
"psr-4": {
23+
"Mailchimp\\WordPress\\": "src/"
24+
},
25+
"classmap": [
26+
"includes"
27+
],
28+
"files": [
29+
"includes/admin/admin-notices.php"
30+
]
31+
},
2132
"config": {
2233
"allow-plugins": {
2334
"dealerdirect/phpcodesniffer-composer-installer": true

includes/class-mailchimp-admin.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212

1313
/**
1414
* Class Mailchimp_Admin
15+
*
16+
* Long term plan is to break up admin functionality into smaller, more focused files to improve maintainability.
17+
* This could also include:
18+
* - Moving OAuth related code to oauth.php
19+
* - Moving account creation code to account.php
20+
* - Moving settings page code to settings.php
21+
* - Moving notices code to notices.php (already done)
22+
* This will help avoid having too much code in a single file and make the codebase more modular.
1523
*
1624
* @since 1.6.0
1725
*/
@@ -38,9 +46,6 @@ public function init() {
3846
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_page_scripts' ) );
3947
add_action( 'admin_menu', array( $this, 'add_create_account_page' ) );
4048
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
41-
42-
// TODO: Should this load somewhere else?
43-
$this->require_admin_utils();
4449
}
4550

4651
/**
@@ -56,9 +61,6 @@ public function init() {
5661
*
5762
* @since 1.7.0
5863
*/
59-
private function require_admin_utils() {
60-
include_once MCSF_DIR . 'includes/admin/admin-notices.php';
61-
}
6264

6365
/**
6466
* Start the OAuth process.

0 commit comments

Comments
 (0)