slug = basename($template, '.php'); $this->templates = array($template); if (self::$base) { $str = substr($template, 0, -4); array_unshift($this->templates, sprintf($str . '-%s.php', self::$base)); } } public function __toString() { $this->templates = apply_filters('bootstrapx_wrap_' . $this->slug, $this->templates); return locate_template($this->templates); } static function wrap($main) { self::$main_template = $main; self::$base = basename(self::$main_template, '.php'); if (self::$base === 'index') { self::$base = false; } return new Bootstrapx_Wrapping(); } } add_filter('template_include', array('Bootstrapx_Wrapping', 'wrap'), 99);