$cache_path)); } Alinks_Registry::set('Alinks_Cacher', $cacher); } catch (Alinks_Cacher_Exception $e) { Alinks_Error::showException($e, Alinks_Error::logException($e)); return; } /** * Setup Alinks_Settings to get aLinks and factory options. */ try { Alinks_Settings::setDb($wpdb, $table_prefix); Alinks_Settings::setCacher($cacher); } catch (Exception $e) { Alinks_Error::showException($e, Alinks_Error::logException($e)); return; } /** * Adds to the registry the path to where aLinks is installed */ Alinks_Registry::set( 'alinks_path', ABSPATH . 'wp-content/plugins/' . plugin_basename(dirname(__FILE__)) ); /** * Adds to the registry the URL to where aLinks is installed */ Alinks_Registry::set( 'alinks_url', Alinks_Settings::get('alinks', 'home') . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__)) ); /** * Get all the defined keyphrases. Setup a shutdown hook that will * take care of saving any changed keyphrases to the database. */ try { $keyphrases = new Alinks_Keyphrase_Keeper($wpdb, $table_prefix, $cacher); Alinks_Registry::set('Alinks_Keyphrase_Keeper', $keyphrases); Alinks_Registry::set('keyphrases', null, array($keyphrases, 'fetchAll')); add_action('shutdown', array($keyphrases, 'shutdown')); } catch (Exception $e) { Alinks_Error::showException($e, Alinks_Error::logException($e)); return; } try { $factories = new Alinks_Factory_Keeper($factories_path, Alinks_Settings::get(), Alinks_Version::VERSION, $wp_version); if (!empty($_FILES)) { /** * @see Alinks_Zip */ require_once('Alinks/Zip.php'); $factories->setZipper(new Alinks_Zip()); } Alinks_Registry::set('Alinks_Factory_Keeper', $factories); Alinks_Registry::set('factories', null, array($factories, 'fetchAll')); } catch (Exception $e) { Alinks_Error::showException($e, Alinks_Error::logException($e)); return; } if (is_admin()) { /** * @see Alinks_Menu */ require_once('Alinks/Menu.php'); $menu = new Alinks_Menu(); $menu->init(); add_action('admin_menu', array($menu, 'add')); /** * @see Alinks_Post_Scraper */ require_once('Alinks/Post/Scraper.php'); add_action('save_post', array(new Alinks_Post_Scraper(), 'scrape')); } if (!Alinks_Ajax::isAjax()) { /** * @see Alinks_Post_Parser */ require_once('Alinks/Post/Parser.php'); /** * Setup the parser. This is the class that actually does the * work of parsing the posts. */ $post_parser = new Alinks_Post_Parser(); $post_parser->setCacher($cacher); add_action('the_content', array($post_parser, 'parse'), 1); add_action('save_post', array($post_parser, 'postUpdated')); add_action('delete_post', array($post_parser, 'postUpdated')); /** * Only if the user wants the comments to be parsed too. By default * we won't do this. */ if (Alinks_Settings::get('alinks', Alinks_Settings::PARSE_COMMENTS, Alinks_Settings::DEFAULT_PARSE_COMMENTS)) { add_action('comment_text', array($post_parser, 'parse'), 1); add_action('edit_comment', array($post_parser, 'commentUpdated')); add_action('delete_comment', array($post_parser, 'commentUpdated')); } } } /** * Called when aLinks is activated */ function alinks_activate() { global $wpdb, $table_prefix; /** * @see Alinks_Install */ require_once('Alinks/Install.php'); $installer = new Alinks_Install(dirname(__FILE__), $wpdb, $table_prefix); $installer->install(); } /** * Handles an installation error * * The Alinks_Install class will set the option 'alinks_error' if there * was an installation error. When aLinks runs, it checks for the presence * of this option. If found, this function is called. * * The function displays an error message to the user, and then deactivates * the plugin. */ function alinks_installation_error() { ?>
aLinks Installation Error