# Hub Connector #
Hub Connector module is used in our free plugins to connect the user websites with Hub.
## Requirements:
* PHP: 7.4+
* WordPress: 5.0+
# How to use it #
1. Insert this repository as **sub-module** into the existing project
2. Include the file `connector.php` in your plugin and initialize it by calling ``\WPMUDEV\Hub\Connector::get();``.
3. Set the plugin specific options (see below for more details) using a unique plugin identifier. Identifier can be any unique string.
``\WPMUDEV\Hub\Connector::get()->set_options( 'blc', $options );``
4. Call the action `wpmudev_hub_connector_ui` where you want the Hub connector UI to render.
5. Done!
### Options
There are a few plugin specific options you need to set in order for this module to work properly without conflicting with other WPMUDEV plugins.
These are the accepted options:
| Option | Type | Sample | Description |
|--------------|-------|------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| `screens` | Array | `array( 'toplevel_page_blc' )` | Array of plugin admin screen IDs. |
| `extra_args` | Array | `array( 'auth' = array( 'ref' => 'blc' ), 'register' => array( 'ref' => 'blc' ) )` | Extra arguments to be added to the URLs of authentication with WPMUDEV.
See more details about the expected items below. |
#### Extra Arguments
Extra custom arguments can be set to URLs used in Hub Connector auth page. Each sub items should contain array of custom arguments (key and value).
Expected items:
| Key | Type | Description |
|-------------------|-------|-----------------------------------------------|
| `auth` | Array | Custom for default login form action URL. |
| `team_auth` | Array | Arguments for team selection form action URL. |
| `google_auth` | Array | Arguments for Google auth form action URL. |
| `register` | Array | Arguments for registration URL. |
| `forgot_password` | Array | Arguments for forgot password URL. |
## Sample Usage
Hub connector should be loaded unconditionally on every page load and admin screen should be set. Otherwise some hooks may not work.
```
set_options( 'blc', $options );
}
// Now conditionally render Hub connector UI somewhere in your plugin.
if ( $my_condition === true ) {
do_action( 'wpmudev_hub_connector_ui', 'blc' );
}
```
## Rendering Hub Connector ##
```
is_logged_in() ) {
// Render Hub connector UI.
do_action( 'wpmudev_hub_connector_ui', 'blc' );
}
```
## Available Helpers ##
```
is_logged_in();;
```
```
get_api_key();
```
```
membership_type();
```
```
profile_data();
```
## Modifying texts ##
You can modify texts in Hub Connector UI using `wpmudev_hub_connector_localize_text_vars` filter.
```