context = new Context( $main_file ); } /** * Retrieves the plugin context object. * * @since 1.0.0 * * @return Context Plugin context. */ public function context() { return $this->context; } /** * Registers the plugin with WordPress. * * @since 1.0.0 */ public function register() { if ( $this->context->is_network_active() ) { add_action( 'network_admin_notices', function() { ?>

not yet compatible for use in a WordPress multisite network, but we’re actively working on that.', 'google-site-kit' ), array( 'strong' => array(), ) ); ?>

', esc_attr( GOOGLESITEKIT_VERSION ) ); }; add_action( 'wp_head', $display_site_kit_meta ); add_action( 'login_head', $display_site_kit_meta ); $options = new Core\Storage\Options( $this->context ); $transients = new Core\Storage\Transients( $this->context ); $assets = new Core\Assets\Assets( $this->context ); $assets->register(); // Initiate the plugin on 'init' for relying on current user being set. add_action( 'init', function() use ( $options, $transients, $assets ) { $user_options = new Core\Storage\User_Options( $this->context, get_current_user_id() ); $authentication = new Core\Authentication\Authentication( $this->context, $options, $user_options, $transients ); $authentication->register(); $modules = new Core\Modules\Modules( $this->context, $options, $user_options, $authentication ); $modules->register(); $permissions = new Core\Permissions\Permissions( $this->context, $authentication ); $permissions->register(); $tracking = new Core\Util\Tracking( $this->context, $authentication ); $tracking->register(); $rest_routes = new Core\REST_API\REST_Routes( $this->context, $authentication, $modules ); $rest_routes->register(); ( new Core\Admin_Bar\Admin_Bar( $this->context, $assets ) )->register(); ( new Core\Admin\Screens( $this->context, $assets ) )->register(); ( new Core\Admin\Notices() )->register(); ( new Core\Admin\Dashboard( $this->context, $assets ) )->register(); // If a login is happening (runs after 'init'), update current user in dependency chain. add_action( 'wp_login', function( $username, $user ) use ( $user_options ) { $user_options->switch_user( $user->ID ); }, -999, 2 ); /** * Fires when Site Kit has fully initialized. * * @since 1.0.0 */ do_action( 'googlesitekit_init' ); }, -999 ); $reset = new Core\Util\Reset( $this->context, $options ); ( new Core\Util\Activation( $this->context, $options, $assets ) )->register(); ( new Core\Util\Beta_Migration( $this->context ) )->register(); ( new Core\Util\Migration_1_0_0( $this->context ) )->register(); ( new Core\Util\Uninstallation( $reset ) )->register(); if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { add_filter( 'debug_bar_panels', function( $panels ) { $panels[] = new Core\Util\Debug_Bar(); return $panels; } ); } } /** * Retrieves the main instance of the plugin. * * @since 1.0.0 * * @return Plugin Plugin main instance. */ public static function instance() { return static::$instance; } /** * Loads the plugin main instance and initializes it. * * @since 1.0.0 * * @param string $main_file Absolute path to the plugin main file. * @return bool True if the plugin main instance could be loaded, false otherwise. */ public static function load( $main_file ) { if ( null !== static::$instance ) { return false; } static::$instance = new static( $main_file ); static::$instance->register(); return true; } }