Skip to content

Commit

Permalink
Merge pull request #10 from jazzsequence:use-root-autoloader
Browse files Browse the repository at this point in the history
Use-root-autoloader
  • Loading branch information
jazzsequence authored Nov 1, 2021
2 parents 6100817 + 4dd4ffa commit 1a90ce1
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
function bootstrap() {
Widget\bootstrap();

if ( parsedown_enabled() ) {
require_once composer_autoloader();
}

if ( ! defined( 'JSDC_REPOSITORY' ) ) {
add_action( 'admin_init', __NAMESPACE__ . '\\add_setting' );
}
Expand All @@ -30,39 +26,14 @@ function bootstrap() {
* @return bool
*/
function parsedown_enabled() : bool {
// Bail if the autoloader doesn't exist.
if ( ! file_exists( composer_autoloader() ) ) {
error_log( __( 'Autoloader file not found.', 'dashboard-changelog' ) );
return false;
}

// Bail if the Parsedown library doesn't exist.
if ( ! file_exists( get_vendor_dir() . 'erusev/parsedown/Parsedown.php' ) ) {
error_log( __( 'Parsedown file does not exist', 'dashboard-changelog' ) );
if ( ! class_exists( 'Parsedown' ) ) { var_dump( 'no parsedown' );
error_log( __( 'Parsedown class does not exist.', 'dashboard-changelog' ) );
return false;
}

return true;
}

/**
* Returns the vendor directory.
*
* @return string
*/
function get_vendor_dir() : string {
return dirname( __DIR__ ) . '/vendor/';
}

/**
* Returns the path to the Composer autoload file.
*
* @return string
*/
function composer_autoloader() : string {
return get_vendor_dir() . 'autoload.php';
}

/**
* Get the cache expiration time.
* We default to one day, but this can be filtered.
Expand Down

0 comments on commit 1a90ce1

Please sign in to comment.