Skip to content

Commit

Permalink
Load admin functions with autoload
Browse files Browse the repository at this point in the history
Set up the structure for classmaps and autoload for future development.
  • Loading branch information
MaxwellGarceau committed Feb 3, 2025
1 parent 7aeb042 commit fe3b7ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
11 changes: 11 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
"10up/phpcs-composer": "^3.0",
"sirbrillig/phpcs-changed": "^2.11"
},
"autoload": {
"psr-4": {
"Mailchimp\\WordPress\\": "src/"
},
"classmap": [
"includes/"
],
"files": [
"includes/admin/admin-notices.php"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
Expand Down
30 changes: 8 additions & 22 deletions includes/class-mailchimp-admin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php
/**
* Class responsible for admin side functionalities.
*
* The long term plan is to break up admin functionality into smaller, more focused
* files to improve maintainability. This could also include:
* - Moving OAuth related code to oauth.php
* - Moving account creation code to account.php
* - Moving settings page code to settings.php
* - Moving notices code to notices.php (already done)
* This will help avoid having too much code in a single file and make the codebase more modular.
*
* @package Mailchimp
*/
Expand Down Expand Up @@ -38,28 +46,6 @@ public function init() {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_page_scripts' ) );
add_action( 'admin_menu', array( $this, 'add_create_account_page' ) );
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );

/**
* Load modularized admin functionality here
*/
$this->require_admin_utils();
}

/**
* Require admin utils.
*
* Currently includes admin notices from a single file. Long term plan is to break up admin
* functionality into smaller, more focused files to improve maintainability. This could also include:
* - Moving OAuth related code to oauth.php
* - Moving account creation code to account.php
* - Moving settings page code to settings.php
* - Moving notices code to notices.php (already done)
* This will help avoid having too much code in a single file and make the codebase more modular.
*
* @since 1.7.0
*/
private function require_admin_utils() {
include_once MCSF_DIR . 'includes/admin/admin-notices.php';
}

/**
Expand Down

0 comments on commit fe3b7ba

Please sign in to comment.