* echo Snippet::get('snippetname'); * echo Snippet::get('snippetname', array('message' => 'Hello World')); * * * @param string $name Snippet file name * @param string $vars Vars * @return string */ public static function get($name, $vars = array()) { $vars['get'] = $name; return Snippet::_content($vars); } /** * Returns snippet content for shortcode {snippet get="snippetname"} * * * {snippet get="snippetname"} * {snippet get="snippetname" message="Hello World"} * * * @param array $attributes Array of attributes * @return string */ public static function _content($attributes) { // Extracst attributes extract($attributes); // Get snippet name $name = (isset($get)) ? (string)$get : ''; // Get snippet path $snippet_path = STORAGE . DS . 'snippets' . DS . $name . '.snippet.php'; // Get snippet content if (File::exists($snippet_path)) { // Turn on output buffering ob_start(); // Include view file include $snippet_path; // Output... return ob_get_clean(); } else { if (Session::exists('admin') && Session::get('admin') == true) { return __('Snippet :name is not found!', 'snippets', array(':name' => $name)); } } } }