Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Remove the Composer-generated autoloader #36

Merged
merged 7 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"type": "wordpress-plugin",
"license": "GPL-2.0",
"require": {
"php": ">=5.2",
"composer/installers": "^1.4",
"xrstf/composer-php52": "^1.0"
"php": ">=5.2"
},
"require-dev": {
"php": "^7.0",
Expand All @@ -31,15 +29,6 @@
]
},
"scripts": {
"post-install-cmd": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"post-update-cmd": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"post-autoload-dump": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"test-coverage": [
"phpunit --testsuite=plugin --coverage-html=tests/coverage"
]
Expand Down
46 changes: 7 additions & 39 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions wc-custom-order-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@
define( 'WC_CUSTOM_ORDER_TABLE_URL', plugin_dir_url( __FILE__ ) );
define( 'WC_CUSTOM_ORDER_TABLE_PATH', plugin_dir_path( __FILE__ ) );

/* Load includes via a PHP 5.2-compatible autoloader. */
if ( file_exists( WC_CUSTOM_ORDER_TABLE_PATH . 'vendor/autoload_52.php' ) ) {
require WC_CUSTOM_ORDER_TABLE_PATH . 'vendor/autoload_52.php';
// phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_set_include_path
set_include_path( get_include_path() . PATH_SEPARATOR . WC_CUSTOM_ORDER_TABLE_PATH . '/includes/' );
// phpcs:enable WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_set_include_path

/**
* Autoloader for plugin files.
*
* This autoloader operates under the assumption that class filenames use the WordPress filename
* conventions, where a class of 'Foo_Bar' would be named 'class-foo-bar.php'.
*
* @param string $class The class name to autoload.
*/
function wc_custom_order_table_autoload( $class ) {
$class = 'class-' . str_replace( '_', '-', $class );

return spl_autoload( $class );
}
spl_autoload_register( 'wc_custom_order_table_autoload' );

/**
* Install the database tables upon plugin activation.
Expand Down