PHPackages                             stellarwp/uplink - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. stellarwp/uplink

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

stellarwp/uplink
================

A library that integrates a WordPress product with the StellarWP Licensing system.

v2.3.1(9mo ago)3452.8k↑96.3%1[8 issues](https://github.com/stellarwp/uplink/issues)[2 PRs](https://github.com/stellarwp/uplink/pulls)GPL-2.0-or-laterPHPPHP &gt;=7.1CI passing

Since Oct 19Pushed 3mo ago19 watchersCompare

[ Source](https://github.com/stellarwp/uplink)[ Packagist](https://packagist.org/packages/stellarwp/uplink)[ RSS](/packages/stellarwp-uplink/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (18)Versions (81)Used By (0)

StellarWP Uplink
================

[](#stellarwp-uplink)

[![CI](https://github.com/stellarwp/uplink/workflows/CI/badge.svg)](https://github.com/stellarwp/uplink/actions?query=branch%3Amain) [![Static Analysis](https://github.com/stellarwp/uplink/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/stellarwp/uplink/actions/workflows/static-analysis.yml)

Installation
------------

[](#installation)

It's recommended that you install Uplink as a project dependency via [Composer](https://getcomposer.org/):

```
composer require stellarwp/uplink
```

> We *actually* recommend that this library gets included in your project using [Strauss](https://github.com/BrianHenryIE/strauss).
>
> Luckily, adding Strauss to your `composer.json` is only slightly more complicated than adding a typical dependency, so checkout our [strauss docs](https://github.com/stellarwp/global-docs/blob/main/docs/strauss-setup.md).

Initialize the library
----------------------

[](#initialize-the-library)

Initializing the StellarWP Uplink library should be done within the `plugins_loaded` action, preferably at priority `0`.

```
use StellarWP\Uplink\Uplink;

add_action( 'plugins_loaded', function() {
	/**
	 * Configure the container.
	 *
	 * The container must be compatible with stellarwp/container-contract.
	 * See here: https://github.com/stellarwp/container-contract#usage.
	 *
	 * If you do not have a container, we recommend https://github.com/lucatume/di52
	 * and the corresponding wrapper:
	 * https://github.com/stellarwp/container-contract/blob/main/examples/di52/Container.php
	 */
	$container = new Container();
	Config::set_container( $container );
	Config::set_hook_prefix( 'my-custom-prefix' );

	/*
	 * If you wish to allow a customer to authorize their product, set your Token Auth Prefix.
	 *
	 * This will allow storage of a unique token associated with the customer's license/domain.
	 *
	 * Important: The Token auth prefix should be the same across all of your products.
	 */
	Config::set_token_auth_prefix( 'my_origin' );

	// Optionally, change the default auth token caching.
	Config::set_auth_cache_expiration( WEEK_IN_SECONDS );

	// Or, disable it completely.
	Config::set_auth_cache_expiration( -1 );

	Uplink::init();
}, 0 );
```

Translation
-----------

[](#translation)

Package is using `__( 'Invalid request: nonce field is expired. Please try again.', '%TEXTDOMAIN%' )` function for translation. In order to change domain placeholder `'%TEXTDOMAIN%'` to your plugin translation domain run

```
./bin/stellar-uplink domain=
```

or

```
./bin/stellar-uplink
```

and prompt the plugin domain You can also add lines below to your composer file in order to run command automatically

```
"scripts": {
	"stellar-uplink": [
	  "vendor/bin/stellar-uplink domain="
	],
	"post-install-cmd": [
	  "@stellar-uplink"
	],
	"post-update-cmd": [
	  "@stellar-uplink"
	]
  }
```

Embedding a license in your plugin
----------------------------------

[](#embedding-a-license-in-your-plugin)

StellarWP Uplink plugins are downloaded with an embedded license key so that users do not need to manually enter the key when activating their plugin. To make this possible, the class must be in a specific location so that the licensing server can find it.

```
# The class file should be in this path:
src/Uplink/Helper.php
```

Note

While the default is `src/Uplink/Helper.php`, the licensing server supports embedding the license in [any file path defined on the server](https://github.com/stellarwp/licensing/blob/e8b0fe1c32065fde198e9d10b9de5c04eda45a9d/src/Licensing/Tables/Products.php#L53).

The file should match the following - keeping the `KEY` constant set to a blank string, or, if you want a default license key, set it to that.:

```
