/** * Process a shortcode. * * @param string $shortcodeName * @param boolean $lowLevel * @param array $atts * @param string $content * @return string */ private static function runShortcode($shortcodeName, $lowLevel, $atts, $content) { // The content of low-level shortcodes is supposed to have been saved in `self::$lowLevelShortcodeContent`. if ($lowLevel && isset($content) && isset(self::$lowLevelShortcodeContent[$content])) { $content = self::$lowLevelShortcodeContent[$content]; } // Print the shortcode. $model = RPBChessboardHelperLoader::loadModel('Shortcode/' . $shortcodeName, $atts, $content); return RPBChessboardHelperLoader::printTemplateOffScreen('Shortcode/' . $shortcodeName, $model); }
/** * Write a file into the cache. Nothing happens if the file already exists. * * @param string $fileName File name, relative to the cache root. * @param string $templateName Template to use to generate the file, if necessary. * @param string $modelName Model to use to generate the file, if necessary. */ public static function ensureExists($fileName, $templateName, $modelName) { $fullFileName = self::getFullFileName($fileName); if (file_exists($fullFileName)) { return; } $model = RPBChessboardHelperLoader::loadModel($modelName); $text = RPBChessboardHelperLoader::printTemplateOffScreen($templateName, $model); $dirName = dirname($fullFileName); if (!file_exists($dirName)) { mkdir($dirName, 0777, true); } file_put_contents($fullFileName, $text); update_option('rpbchessboard_cache_' . $fileName, uniqid()); }