public static function init() { $dir = AvadaRedux_Helpers::cleanFilePath(dirname(__FILE__)); // Windows-proof constants: replace backward by forward slashes. Thanks to: @peterbouwmeester self::$_dir = trailingslashit($dir); self::$wp_content_url = trailingslashit(AvadaRedux_Helpers::cleanFilePath(is_ssl() ? str_replace('http://', 'https://', WP_CONTENT_URL) : WP_CONTENT_URL)); // See if AvadaRedux is a plugin or not if (strpos(AvadaRedux_Helpers::cleanFilePath(__FILE__), AvadaRedux_Helpers::cleanFilePath(get_stylesheet_directory())) !== false || strpos(AvadaRedux_Helpers::cleanFilePath(__FILE__), AvadaRedux_Helpers::cleanFilePath(get_template_directory_uri())) !== false || strpos(AvadaRedux_Helpers::cleanFilePath(__FILE__), AvadaRedux_Helpers::cleanFilePath(WP_CONTENT_DIR . '/themes/')) !== false) { self::$_is_plugin = false; } else { // Check if plugin is a symbolic link, see if it's a plugin. If embedded, we can't do a thing. if (strpos(self::$_dir, ABSPATH) === false) { if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $is_plugin = false; foreach (get_plugins() as $key => $value) { if (is_plugin_active($key) && strpos($key, 'avadaredux-framework.php') !== false) { self::$_dir = trailingslashit(AvadaRedux_Helpers::cleanFilePath(WP_CONTENT_DIR . '/plugins/' . plugin_dir_path($key) . 'AvadaReduxCore/')); $is_plugin = true; } } if (!$is_plugin) { self::$_is_plugin = false; } } } if (self::$_is_plugin == true || self::$_as_plugin == true) { self::$_url = plugin_dir_url(__FILE__); } else { if (strpos(AvadaRedux_Helpers::cleanFilePath(__FILE__), AvadaRedux_Helpers::cleanFilePath(get_template_directory())) !== false) { $relative_url = str_replace(AvadaRedux_Helpers::cleanFilePath(get_template_directory()), '', self::$_dir); self::$_url = trailingslashit(get_template_directory_uri() . $relative_url); } else { if (strpos(AvadaRedux_Helpers::cleanFilePath(__FILE__), AvadaRedux_Helpers::cleanFilePath(get_stylesheet_directory())) !== false) { $relative_url = str_replace(AvadaRedux_Helpers::cleanFilePath(get_stylesheet_directory()), '', self::$_dir); self::$_url = trailingslashit(get_stylesheet_directory_uri() . $relative_url); } else { $wp_content_dir = trailingslashit(AvadaRedux_Helpers::cleanFilePath(WP_CONTENT_DIR)); $wp_content_dir = trailingslashit(str_replace('//', '/', $wp_content_dir)); $relative_url = str_replace($wp_content_dir, '', self::$_dir); self::$_url = trailingslashit(self::$wp_content_url . $relative_url); } } } self::$_url = apply_filters("avadaredux/_url", self::$_url); self::$_dir = apply_filters("avadaredux/_dir", self::$_dir); self::$_is_plugin = apply_filters("avadaredux/_is_plugin", self::$_is_plugin); }