1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77:
<?php
class Inbound_Extension_Loads {
public function __construct() {
self::load_hooks();
self::load_extensions();
}
public static function load_hooks() {
add_filter( 'plugins_url' , array( __CLASS__ , 'alter_constants' ) , 1 , 3 );
}
public static function load_extensions() {
if ( INBOUND_ACCESS_LEVEL == 0 || INBOUND_ACCESS_LEVEL == 9 ) {
return;
}
$configuration = Inbound_Options_API::get_option( 'inbound-pro' , 'configuration' , array() );
foreach( $configuration as $key => $extension){
if ( $extension['status'] != 'installed' || $extension['download_type'] != 'extension' || !isset($extension['filename']) ) {
continue;
}
if ( file_exists( $extension['upload_path'] . '/' . $extension['filename'] . '.php' ) ) {
include_once( $extension['upload_path'] . '/' . $extension['filename'] . '.php' );
}
else {
$parts = explode('extensions/' , $extension['upload_path']);
$slug = end($parts);
if ( file_exists( INBOUND_PRO_UPLOADS_PATH . 'extensions/'. $slug . '/' . $extension['filename'] . '.php' ) ) {
include_once( INBOUND_PRO_UPLOADS_PATH . 'extensions/'.$slug . '/' . $extension['filename'] . '.php' );
}
}
}
}
public static function alter_constants( $url, $path, $plugin ) {
if ( !strstr($plugin , 'uploads/inbound-pro/extensions/' ) ) {
return $url;
}
$parts = explode( 'uploads/inbound-pro/' , $plugin );
$extension = explode( '/' , $parts[1]) ;
return INBOUND_PRO_UPLOADS_URLPATH . 'extensions/' . $extension[1] . '/';
}
}
new Inbound_Extension_Loads();