1. Go to this page and download the library: Download stellarwp/uplink library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stellarwp / uplink example snippets
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 );
declare( strict_types=1 );
namespace Whatever\Namespace\Uplink;
final class Helper {
public const KEY = '';
}
use StellarWP\Uplink\Register;
$plugin_slug = 'my-plugin';
$plugin_name = 'My Plugin';
$plugin_version = MyPlugin::VERSION;
$plugin_path = 'my-plugin/my-plugin.php';
$plugin_class = MyPlugin::class;
$license_class = MyPlugin\Uplink\Helper::class;
Register::plugin(
$plugin_slug,
$plugin_name,
$plugin_version,
$plugin_path,
$plugin_class,
$license_class, // This is optional.
false // Whether this is an oAuth plugin. Default false.
);
use StellarWP\Uplink as UplinkNamespace;
$form = UplinkNamespace\get_form();
$plugins = UplinkNamespace\get_plugins();
foreach ( $plugins as $plugin ) {
$field = UplinkNamespace\get_field( $plugin->get_slug() );
// Tha name property of the input field.
$field->set_field_name( 'field-' . $slug );
$form->add_field( $field );
}
$form->render();
// or echo $form->get_render_html();
use StellarWP\Uplink as UplinkNamespace;
$field = UplinkNamespace\get_field( 'my-test-plugin' );
$field->render();
// or echo $field->get_render_html();
use StellarWP\Uplink as UplinkNamespace;
function render_settings_page() {
// ...
$form = UplinkNamespace\get_form();
$plugins = UplinkNamespace\get_plugins();
foreach ( $plugins as $plugin ) {
$field = UplinkNamespace\get_field( $plugin->get_slug() );
// Tha name property of the input field.
$field->set_field_name( 'field-' . $slug );
$form->add_field( $field );
}
$form->show_button( true, __( 'Submit', 'text-domain' ) );
$form->render();
//....
}
// Call the namespaced function with your plugin slug.
\StellarWP\Uplink\render_authorize_button( 'kadence-blocks-pro' );
// Call the namespaced function with your plugin slug and license domain.
\StellarWP\Uplink\render_authorize_button( 'kadence-blocks-pro', 'customer-site.com' );