Skip to content

Commit fe3b7ba

Browse files
Load admin functions with autoload
Set up the structure for classmaps and autoload for future development.
1 parent 7aeb042 commit fe3b7ba

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

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 & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
22
/**
33
* Class responsible for admin side functionalities.
4+
*
5+
* The long term plan is to break up admin functionality into smaller, more focused
6+
* files to improve maintainability. This could also include:
7+
* - Moving OAuth related code to oauth.php
8+
* - Moving account creation code to account.php
9+
* - Moving settings page code to settings.php
10+
* - Moving notices code to notices.php (already done)
11+
* This will help avoid having too much code in a single file and make the codebase more modular.
412
*
513
* @package Mailchimp
614
*/
@@ -38,28 +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-
/**
43-
* Load modularized admin functionality here
44-
*/
45-
$this->require_admin_utils();
46-
}
47-
48-
/**
49-
* Require admin utils.
50-
*
51-
* Currently includes admin notices from a single file. Long term plan is to break up admin
52-
* functionality into smaller, more focused files to improve maintainability. This could also include:
53-
* - Moving OAuth related code to oauth.php
54-
* - Moving account creation code to account.php
55-
* - Moving settings page code to settings.php
56-
* - Moving notices code to notices.php (already done)
57-
* This will help avoid having too much code in a single file and make the codebase more modular.
58-
*
59-
* @since 1.7.0
60-
*/
61-
private function require_admin_utils() {
62-
include_once MCSF_DIR . 'includes/admin/admin-notices.php';
6349
}
6450

6551
/**

0 commit comments

Comments
 (0)