/** * Constructor * * @access private * @return void */ private function __construct() { // set list of all multi-languages plugins classes $this->classes = array(array('dir' => KocujSitemapPlugin::getInstance()->getPluginDir() . '/classes/multilang/qtranslate.class.php', 'class' => 'kocujsitemap_qtranslate', 'original' => true)); // get list of additional multi-languages plugins classes $additionalMultiLangClasses = apply_filters('kocujsitemap_additionalmultilangphpclasses', array()); if (!empty($additionalMultiLangClasses)) { $ok = true; foreach ($additionalMultiLangClasses as $val) { if (!isset($val['dir']) || !isset($val['class'])) { $ok = false; } } if (!empty($ok)) { $this->classes = array_merge($this->classes, $additionalMultiLangClasses); foreach ($this->classes as $key => $val) { $this->classes[$key]['original'] = false; } } } // load all classes if (!empty($this->classes)) { $methods = array('getInstance', 'getName', 'getLanguages', 'checkPluginAdmin', 'checkPlugin', 'beforeGetBlogName', 'afterGetBlogName', 'getTranslatedBlogName', 'beforeGetHomeURL', 'afterGetHomeURL', 'getTranslatedHomeURL', 'beforeGetPages', 'afterGetPages', 'beforeGetPageItem', 'afterGetPageItem', 'getTranslatedPageURL', 'getTranslatedPageTitle', 'beforeGetPosts', 'afterGetPosts', 'beforeGetPostItem', 'afterGetPostItem', 'getTranslatedPostURL', 'getTranslatedPostTitle', 'beforeGetCategories', 'afterGetCategories', 'beforeGetCategoryItem', 'afterGetCategoryItem', 'getTranslatedCategoryURL', 'getTranslatedCategoryTitle', 'beforeGetMenu', 'afterGetMenu', 'beforeGetMenuItem', 'afterGetMenuItem', 'getTranslatedMenuURL', 'getTranslatedMenuTitle'); foreach ($this->classes as $key => $class) { $ok = false; if (file_exists($class['dir'])) { include_once $class['dir']; if (class_exists('KocujSitemapPluginMultiLang_' . $class['class'])) { $ok = true; eval('$instance = KocujSitemapPluginMultiLang_' . $class['class'] . '::getInstance();'); if (empty($class['original'])) { foreach ($methods as $method) { if (!method_exists($instance, $method)) { $ok = false; break; } } } if (!empty($ok)) { $activeAdmin = $instance->checkPluginAdmin(); if (!empty($activeAdmin)) { $name = $instance->getName(); $active = $instance->checkPlugin(); $this->data[$key] = array('instance' => $instance, 'active' => $active, 'admin_id' => 'MultiLang_' . $class['class'], 'admin_label' => sprintf(__('Use %s plugin', 'kocuj-sitemap'), $name), 'admin_description' => sprintf(__('Use %s plugin (if installed and activated) for multi-language websites; uncheck it only if you have any problems because of this setting', 'kocuj-sitemap'), $name)); } else { $ok = false; } } } } if (empty($ok)) { unset($this->classes[$key]); } } } }
/** * Get singleton instance * * @access public * @return object Singleton instance */ public static function getInstance() { // optionally create new instance if (!self::$instance) { self::$instance = new KocujSitemapPlugin(); } // exit return self::$instance; }
/** * Get cache directory * * @access private * @return string Cache directory */ private function getCacheDirectory() { // get cache directory return KocujSitemapPlugin::getInstance()->getPluginDir() . '/cache'; }