testHost()) { return; } add_action('init', array($this, 'textDomain')); register_uninstall_hook(__FILE__, array(__CLASS__, 'uninstall')); new Ajungo_Admin; new Ajungo_Code; } /** * PSR-0 compliant autoloader to load classes as needed. * * @param string $classname The name of the class * @return null Return early if the class name does not start with the * correct prefix */ public static function autoload($className) { if (__CLASS__ !== mb_substr($className, 0, strlen(__CLASS__))) { return; } $className = ltrim($className, '\\'); $fileName = ''; $namespace = ''; if ($lastNsPos = strrpos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace); $fileName .= DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, 'src_'.$className); $fileName .='.php'; require $fileName; } /** * Loads the plugin text domain for translation */ public function textDomain() { $domain = self::TEXT_DOMAIN; $locale = apply_filters('plugin_locale', get_locale(), $domain); load_textdomain( $domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo' ); load_plugin_textdomain( $domain, false, dirname(plugin_basename(__FILE__)).'/lang/' ); } /** * Fired when the plugin is uninstalled. */ public function uninstall() { delete_option(self::OPTION_KEY); } // ------------------------------------------------------------------------- // Environment Checks // ------------------------------------------------------------------------- /** * Checks PHP and WordPress versions. */ private function testHost() { // Check if PHP is too old if (version_compare(PHP_VERSION, self::MIN_PHP_VERSION, '<')) { // Display notice add_action('admin_notices', array(&$this, 'phpVersionError')); return false; } // Check if WordPress is too old global $wp_version; if (version_compare($wp_version, self::MIN_WP_VERSION, '<')) { add_action('admin_notices', array(&$this, 'wpVersionError')); return false; } return true; } /** * Displays a warning when installed on an old PHP version. */ public function phpVersionError() { echo '

'; printf( 'Error: %3$s requires PHP version %1$s or greater.
'. 'Your installed PHP version: %2$s', self::MIN_PHP_VERSION, PHP_VERSION, $this->getPluginName() ); echo '

'; } /** * Displays a warning when installed in an old Wordpress version. */ public function wpVersionError() { echo '

'; printf( 'Error: %2$s requires WordPress version %1$s or greater.', self::MIN_WP_VERSION, $this->getPluginName() ); echo '

'; } /** * Get the name of this plugin. * * @return string The plugin name. */ private function getPluginName() { $data = get_plugin_data(self::FILE); return $data['Name']; } } add_action('plugins_loaded', array('Ajungo', 'getInstance'));