tracking-code-manager
Last commit date
assets
1 year ago
includes
1 year ago
languages
1 year ago
.gitattributes
1 year ago
.gitignore
1 year ago
LICENSE
1 year ago
autoload.php
1 year ago
index.php
1 year ago
readme.txt
1 year ago
screenshot-1.png
1 year ago
screenshot-2.png
1 year ago
screenshot-3.png
1 year ago
screenshot-4.png
1 year ago
screenshot-5.png
1 year ago
tcmp_free_wp_kses_tags_attrs.php
1 year ago
autoload.php
49 lines
| 1 | <?php |
| 2 | spl_autoload_register( 'tcmp_autoload' ); |
| 3 | function tcmp_autoload( $class ) { |
| 4 | $root = dirname( __FILE__ ) . '/includes/classes/'; |
| 5 | tcmp_autoload_root( $root, $class ); |
| 6 | } |
| 7 | function tcmp_autoload_root( $root, $class ) { |
| 8 | $slash = substr( $root, strlen( $root ) - 1 ); |
| 9 | if ( '/' !== $slash && '\\' !== $slash ) { |
| 10 | $root .= '/'; |
| 11 | } |
| 12 | $name = str_replace( TCMP_PLUGIN_PREFIX, '', $class ); |
| 13 | if ( strpos( $class, TCMP_PLUGIN_PREFIX ) === false ) { |
| 14 | //autoload only plugin classes |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | $h = opendir( $root ); |
| 19 | while ( $file = readdir( $h ) ) { |
| 20 | if ( is_dir( $root . $file ) && '.' !== $file && '..' !== $file ) { |
| 21 | tcmp_autoload_root( $root . $file, $class ); |
| 22 | } elseif ( file_exists( $root . $name . '.php' ) ) { |
| 23 | include_once( $root . $name . '.php' ); |
| 24 | } elseif ( file_exists( $root . $class . '.php' ) ) { |
| 25 | include_once( $root . $class . '.php' ); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | function tcmp_include_php( $root ) { |
| 30 | $h = opendir( $root ); |
| 31 | $slash = substr( $root, strlen( $root ) - 1 ); |
| 32 | if ( '/' !== $slash && '\\' !== $slash ) { |
| 33 | $root .= '/'; |
| 34 | } |
| 35 | |
| 36 | while ( $file = readdir( $h ) ) { |
| 37 | if ( is_dir( $root . $file ) && '.' !== $file && '..' !== $file ) { |
| 38 | tcmp_include_php( $root . $file ); |
| 39 | } elseif ( strlen( $file ) > 5 ) { |
| 40 | $ext = '.php'; |
| 41 | $length = strlen( $ext ); |
| 42 | $start = $length * -1; //negative |
| 43 | if ( strcasecmp( substr( $file, $start ), $ext ) === 0 ) { |
| 44 | include_once( $root . $file ); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 |