/** * Generates a template array by the given template directory path. * * @remark The directory must have necessary template files including style.css and tmplate.php * @access public This is access by the pro classes. */ public function getTemplateArray($strDirPath) { // Check mandatory files. if (!$this->doFilesExist(array($strDirPath . DIRECTORY_SEPARATOR . 'style.css', $strDirPath . DIRECTORY_SEPARATOR . 'template.php'))) { return; } return array('strCSSPath' => $strDirPath . DIRECTORY_SEPARATOR . 'style.css', 'strTemplatePath' => $strDirPath . DIRECTORY_SEPARATOR . 'template.php', 'strDirPath' => $strDirPath, 'strFunctionsPath' => file_exists($strDirPath . DIRECTORY_SEPARATOR . 'functions.php') ? $strDirPath . DIRECTORY_SEPARATOR . 'functions.php' : null, 'strSettingsPath' => file_exists($strDirPath . DIRECTORY_SEPARATOR . 'settings.php') ? $strDirPath . DIRECTORY_SEPARATOR . 'settings.php' : null, 'strThumbnailPath' => $this->getScreenshotPath($strDirPath), 'strID' => md5(AmazonAutoLinks_Utilities::getRelativePath(ABSPATH, $strDirPath))) + $this->getTemplateData($strDirPath . DIRECTORY_SEPARATOR . 'style.css') + self::$arrStructure_Template; }
/** * Calculates the URL from the given path. * * * * @static * @access public * @return string The source url * @since 2.0.1 * @since 2.0.3.1 Prevented "/./" to be inserted in the url. */ public static function getSRCFromPath($strFilePath) { $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. $strRelativePath = AmazonAutoLinks_Utilities::getRelativePath(ABSPATH, $strFilePath); $strRelativePath = preg_replace("/^\\.[\\/\\\\]/", '', $strRelativePath, 1); // removes the heading ./ or .\ $sHref = trailingslashit($oWPStyles->base_url) . $strRelativePath; return esc_url($sHref); }