# posts-data-table/1.3.1/autoloader.php

Posts Table with Search &amp; Sort, version 1.3.1. 46 lines.

- Page: https://pluginprobe.com/plugins/posts-data-table/1.3.1/code/autoloader.php
- Raw: https://pluginprobe.com/plugins/posts-data-table/1.3.1/raw/autoloader.php
- Modified: 2019-11-16T17:52:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/posts-data-table/1.3.1/code/autoloader.php#L10-L20`.

```php
<?php

spl_autoload_register( function( $class ) {
    $namespace = 'Barn2\\Plugin\\Posts_Table_Search_Sort';
    $src_path  = __DIR__ . '/src';

    // Bail if the class is not in our namespace.
    if ( 0 !== strpos( $class, $namespace ) ) {
        return;
    }

    // Remove the namespace.
    $class = str_replace( $namespace, '', $class );

    // Build the filename - realpath returns false if file doesn't exist.
    $file = realpath( $src_path . '/' . str_replace( '\\', '/', $class ) . '.php' );

    // If the file exists for the class name, load it.
    if ( $file ) {
        include_once $file;
    }
}
);

spl_autoload_register( function( $class ) {
    $namespace = 'Barn2\\Lib';
    $lib_path  = __DIR__ . '/lib';

    // Bail if the class is not in our namespace.
    if ( 0 !== strpos( $class, $namespace ) ) {
        return;
    }

    // Remove the namespace.
    $class = str_replace( $namespace, '', $class );

    // Build the filename - realpath returns false if file doesn't exist.
    $file = realpath( $lib_path . '/' . str_replace( '\\', '/', $class ) . '.php' );

    // If the file exists for the class name, load it.
    if ( $file ) {
        include_once $file;
    }
}
);

```
