Skip to content

Commit

Permalink
Rename includes folder to `classes & move autoloader to plugin file
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Apr 5, 2024
1 parent 03af73a commit 8aa63e7
Show file tree
Hide file tree
Showing 50 changed files with 27 additions and 32 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 0 additions & 31 deletions includes/autoload.php

This file was deleted.

28 changes: 27 additions & 1 deletion progress-planner.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,33 @@
define( 'PROGRESS_PLANNER_DIR', __DIR__ );
define( 'PROGRESS_PLANNER_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );

require_once PROGRESS_PLANNER_DIR . '/includes/autoload.php';
/**
* Autoload classes.
*/
spl_autoload_register(
function ( $class_name ) {
$prefix = 'ProgressPlanner\\';

if ( 0 !== \strpos( $class_name, $prefix ) ) {
return;
}

$class_name = \str_replace( $prefix, '', $class_name );

$parts = \explode( '\\', $class_name );
$file = PROGRESS_PLANNER_DIR . '/classes/';
$last = \array_pop( $parts );

foreach ( $parts as $part ) {
$file .= strtolower( $part ) . '/';
}
$file .= 'class-' . \str_replace( '_', '-', \strtolower( $last ) ) . '.php';

if ( \file_exists( $file ) ) {
require_once $file;
}
}
);

/**
* Get the progress planner instance.
Expand Down

0 comments on commit 8aa63e7

Please sign in to comment.