public static function getSRCFromPath($sFilePath) { $_oWPStyles = new WP_Styles(); $_sRelativePath = AdminPageFramework_Utility::getRelativePath(ABSPATH, $sFilePath); $_sRelativePath = preg_replace("/^\\.[\\/\\\\]/", '', $_sRelativePath, 1); $_sHref = trailingslashit($_oWPStyles->base_url) . $_sRelativePath; unset($_oWPStyles); return $_sHref; }
/** * Calculates the URL from the given path. * * @since 2.1.5 * @static * @access public * @return string The source url */ public static function getSRCFromPath($sFilePath) { $oWPStyles = new WP_Styles(); // It doesn't matter whether the file is a style or not. Just use the built-in WordPress class to calculate the SRC URL. $sRelativePath = AdminPageFramework_Utility::getRelativePath(ABSPATH, $sFilePath); $sRelativePath = preg_replace("/^\\.[\\/\\\\]/", '', $sRelativePath, 1); // removes the heading ./ or .\ $sHref = trailingslashit($oWPStyles->base_url) . $sRelativePath; unset($oWPStyles); // for PHP 5.2.x or below return esc_url($sHref); }