boot(); } return self::$instance; } /** * Wires services and hooks. * * @return void */ private function boot() { $this->links = new LinkTender_Links(); $this->scanner = new LinkTender_Scanner( $this->links ); $this->checker = new LinkTender_Checker(); $this->queue = new LinkTender_Queue( $this->links, $this->scanner, $this->checker ); $this->editor = new LinkTender_Editor( $this->links, $this->scanner ); $this->scanner->hooks(); $this->queue->hooks(); ( new LinkTender_Frontend() )->hooks(); // Creates or upgrades the tables when an admin screen is opened (also covers sites of a very // large network that a network activation has not reached yet). Background batches upgrade // too. Front-end page views never change the database schema. add_action( 'admin_init', array( 'LinkTender_Install', 'maybe_upgrade' ), 0 ); add_action( 'wp_initialize_site', array( $this, 'new_site' ), 200 ); add_action( LinkTender_Install::NETWORK_HOOK, array( 'LinkTender_Install', 'continue_network_install' ) ); add_filter( 'wpmu_drop_tables', array( 'LinkTender_Install', 'drop_site_tables' ) ); if ( is_admin() && class_exists( 'LinkTender_Admin' ) ) { $this->admin = new LinkTender_Admin( $this ); $this->admin->hooks(); } /** * Fires when LinkTender is ready. Add-ons should hook here. * * @param LinkTender_Plugin $plugin Plugin instance. */ do_action( 'linktender_loaded', $this ); } /** * Sets up a new multisite site when the plugin is network-active. * * @param WP_Site $site New site. * @return void */ public function new_site( $site ) { if ( ! function_exists( 'is_plugin_active_for_network' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } if ( ! is_plugin_active_for_network( plugin_basename( LINKTENDER_FILE ) ) ) { return; } switch_to_blog( $site->blog_id ); LinkTender_Install::install_site(); restore_current_blog(); } /** * Capability needed to use the plugin screens. * * @return string */ public static function capability() { /** * Filters the capability required to view and fix links. * * @param string $cap Capability. */ return apply_filters( 'linktender_capability', 'edit_others_posts' ); } }