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

Commit

Permalink
Merge pull request #36 from liquidweb/fix/remove-autoloader
Browse files Browse the repository at this point in the history
Remove the Composer-generated autoloader
  • Loading branch information
stevegrunwell authored Jan 23, 2018
2 parents 90012de + 1c37506 commit 9a95351
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 50 deletions.
13 changes: 1 addition & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
}
],
"require": {
"php": ">=5.2",
"composer/installers": "^1.4",
"xrstf/composer-php52": "^1.0"
"php": ">=5.2"
},
"require-dev": {
"php": "^7.0",
Expand All @@ -37,15 +35,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
38 changes: 3 additions & 35 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

0 comments on commit 9a95351

Please sign in to comment.