Skip to content

Commit af49dcc

Browse files
committed
feat: add PSR-4 autoloading for plugin classes
Configures Composer to use PSR-4 for the `Blockparty\Faq\` namespace. This involves adding the `autoload` section to `composer.json`, including `vendor/autoload.php`, and renaming class directories (e.g., `schema` to `Schema`) to align with PSR-4 capitalization standards. This improves class management, code organization, and facilitates future development by adhering to modern PHP practices.
1 parent 11a4c9b commit af49dcc

10 files changed

Lines changed: 17 additions & 8 deletions

blockparty-faq.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,27 @@
4040
die( '-1' );
4141
}
4242

43+
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
44+
include_once __DIR__ . '/vendor/autoload.php';
45+
}
46+
4347
// Plugin constants
4448
define( 'BLOCKPARTY_FAQ_VERSION', '2.0.3' );
4549

4650
// Plugin URL and PATH
4751
define( 'BLOCKPARTY_FAQ_DIR', plugin_dir_path( __FILE__ ) );
4852

4953
// Schema & SEO services
50-
require_once BLOCKPARTY_FAQ_DIR . 'includes/schema/FAQ_Schema_Generator.php';
51-
require_once BLOCKPARTY_FAQ_DIR . 'includes/schema/FAQ_Schema.php';
52-
require_once BLOCKPARTY_FAQ_DIR . 'includes/services/Seo_Service_Interface.php';
53-
require_once BLOCKPARTY_FAQ_DIR . 'includes/services/Yoast_Seo_Service.php';
54-
require_once BLOCKPARTY_FAQ_DIR . 'includes/services/Rank_Math_Seo_Service.php';
55-
require_once BLOCKPARTY_FAQ_DIR . 'includes/services/Seopress_Seo_Service.php';
56-
require_once BLOCKPARTY_FAQ_DIR . 'includes/services/Seo_Service_Resolver.php';
54+
require_once BLOCKPARTY_FAQ_DIR . 'includes/Schema/FAQ_Schema_Generator.php';
55+
require_once BLOCKPARTY_FAQ_DIR . 'includes/Schema/FAQ_Schema.php';
56+
require_once BLOCKPARTY_FAQ_DIR . 'includes/Services/Seo_Service_Interface.php';
57+
require_once BLOCKPARTY_FAQ_DIR . 'includes/Services/Yoast_Seo_Service.php';
58+
require_once BLOCKPARTY_FAQ_DIR . 'includes/Services/Rank_Math_Seo_Service.php';
59+
require_once BLOCKPARTY_FAQ_DIR . 'includes/Services/Seopress_Seo_Service.php';
60+
require_once BLOCKPARTY_FAQ_DIR . 'includes/Services/Seo_Service_Resolver.php';
5761

5862
// Hooks
59-
require_once BLOCKPARTY_FAQ_DIR . 'includes/hooks/Schema_Hooks.php';
63+
require_once BLOCKPARTY_FAQ_DIR . 'includes/Hooks/Schema_Hooks.php';
6064

6165
/**
6266
* Initialize plugin blocks.

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
"url": "https://repo.wp-packages.org"
6161
}
6262
],
63+
"autoload": {
64+
"psr-4": {
65+
"Blockparty\\Faq\\": "includes/"
66+
}
67+
},
6368
"scripts": {
6469
"cs": "./vendor/bin/phpcs",
6570
"cb": "./vendor/bin/phpcbf"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)