PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / trunk
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin vtrunk
1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 0.8.6 All 33 releases
desktop-mode / includes / network / bootstrap.php

bootstrap.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin trunk, at includes/network/bootstrap.php

85 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation — Network bootstrap.
4 *
5 * Loads the OpenStation Network module: the keypair, the identity
6 * route, the registry, the hub's list route, the member's join and
7 * refresh, and the hop token that logs a user in on arrival at another
8 * install. The Network window (`apps/network/`) checks the same switch
9 * and stays out of the app registry while it is off.
10 *
11 * The whole module is gated on the site-wide `network` extended option
12 * (OpenStation Preferences → Features → Extended options, admins
13 * only), which is OFF by default — the network is opt-in. While the
14 * option is off none of the module files load: no keypair is minted,
15 * no REST route registered, no cron scheduled, no token minted or
16 * spent, no window offered, and the switcher a multisite has on its
17 * own stays exactly as it is. The module costs nothing beyond the
18 * option read below. Pairings already made are options that survive
19 * a disable and are back when the option is on again.
20 *
21 * Loading is deferred to `plugins_loaded` (priority 5) so any regular
22 * plugin can hook the `openstation_network_enabled` filter in time to
23 * influence the decision. New `require_once` lines belong in the
24 * loader below so the rest of the codebase keeps loading the feature
25 * through one entry point.
26 *
27 * @package OpenStation
28 */
29
30 defined( 'ABSPATH' ) || exit;
31
32 /**
33 * The token's query arg on the target's shell screen. Defined here,
34 * not in the hop module, because the shell screen strips and reads
35 * these boot args whether or not the module loaded.
36 */
37 const OPENSTATION_NETWORK_HOP_ARG = 'openstation_hop';
38
39 /** The slide direction the target lands with, after the token is spent. */
40 const OPENSTATION_NETWORK_HOP_FROM_ARG = 'openstation_hop_from';
41
42 /**
43 * Whether the OpenStation Network is enabled site-wide.
44 *
45 * Backed by the `network` key of the extended options bundle
46 * (`openstation_get_extended_options()`), default off — opt-in.
47 *
48 * @return bool
49 */
50 function openstation_network_enabled() {
51 $options = openstation_get_extended_options();
52 $enabled = ! empty( $options['network'] );
53
54 /**
55 * Filters whether the OpenStation Network is enabled site-wide.
56 *
57 * Runs on `plugins_loaded` (priority 5) to decide whether the
58 * network module loads at all, and again at runtime wherever the
59 * enabled state is consulted (the switcher's payload, the shell
60 * config).
61 *
62 * @param bool $enabled Whether the network is enabled.
63 */
64 return (bool) apply_filters( 'openstation_network_enabled', $enabled );
65 }
66
67 /**
68 * Loads the network module when the network is enabled.
69 *
70 * @access private
71 */
72 function openstation_network_load() {
73 if ( ! openstation_network_enabled() ) {
74 return;
75 }
76
77 require_once OPENSTATION_DIR . 'includes/network/keys.php';
78 require_once OPENSTATION_DIR . 'includes/network/identity.php';
79 require_once OPENSTATION_DIR . 'includes/network/registry.php';
80 require_once OPENSTATION_DIR . 'includes/network/hub.php';
81 require_once OPENSTATION_DIR . 'includes/network/member.php';
82 require_once OPENSTATION_DIR . 'includes/network/hop.php';
83 }
84 add_action( 'plugins_loaded', 'openstation_network_load', 5 );
85