return error if class does not exist or is not readable
This commit is contained in:
parent
663c6315c9
commit
0685763424
1 changed files with 5 additions and 2 deletions
|
@ -55,11 +55,11 @@ function init() {
|
|||
* Class Autoloader
|
||||
*/
|
||||
spl_autoload_register(
|
||||
function ( $class ) {
|
||||
function ( $full_class ) {
|
||||
$base_dir = \dirname( __FILE__ ) . '/includes/';
|
||||
$base = 'activitypub';
|
||||
|
||||
$class = strtolower( $class );
|
||||
$class = strtolower( $full_class );
|
||||
|
||||
if ( strncmp( $class, $base, strlen( $base ) ) === 0 ) {
|
||||
$class = str_replace( 'activitypub\\', '', $class );
|
||||
|
@ -76,6 +76,9 @@ spl_autoload_register(
|
|||
|
||||
if ( file_exists( $file ) && is_readable( $file ) ) {
|
||||
require_once $file;
|
||||
} else {
|
||||
// translators: %s is the class name
|
||||
\wp_die( sprintf( esc_html__( 'Required class not found or not readable: %s', 'activitypub' ), esc_html( $full_class ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue