/** * 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()); }
public static function callbackInlinedScripts() { $model = RPBChessboardHelperLoader::loadModel('Common/Compatibility'); RPBChessboardHelperLoader::printTemplate('Localization', $model); }
/** * Load the model `$postModelName`, and execute the method `$methodName` supposingly defined by this model. * * @param object $model * @param string $postModelName * @param string $methodName * @param string $capability Required capability to execute the action. Default is `'manage_options'`. */ private static function executeAction($model, $postModelName, $methodName, $capability = 'manage_options') { if (!current_user_can($capability)) { return; } $postModel = RPBChessboardHelperLoader::loadModel('Post/' . $postModelName); $model->setPostMessage($postModel->{$methodName}()); }