Inloggen
Aan de slag

Easy Digital Downloads Documentatie

Documentatie, Referentiemateriaal en Tutorials voor Easy Digital Downloads 

Softwarelicenties – Implementatie van de updater voor WordPress-thema's

Met de Software Licensing extensie voor Easy Digital Downloads kunt u automatische upgrades voor thema's instellen. Dit betekent niet dat het thema van uw klant zichzelf zal updaten, maar eerder dat uw klant hun thema kan updaten met behulp van de traditionele WordPress-updatetools, alsof het thema op WordPress.org zou zijn gehost.

Er zijn twee hoofdonderdelen aan het voorbeeld:

  1. Het composer.json bestand dat alles instelt wat u nodig hebt om te beginnen met de Software Licensing API in uw WordPress-plugin.
  2. Het functions.php bestand, dat de code bevat om te koppelen met de EDD Software Licensing SDK, een drop-in oplossing voor ontwikkelaars van WordPress-plugins en -thema's om Easy Digital Downloads Software Licensing snel in hun producten te integreren zonder complexe installatie of aangepaste beheerdersinterfaces.

Stap 1: Installeer het composer-pakket

Werk het composer.json-bestand voor uw plugin bij (of maak het aan) in uw hoofdpluginmap. Voer composer install uit om de Software Licensing SDK aan uw plugin toe te voegen (merk op dat deze link ook de laatste instructies en voorbeelden bevat).

Stap 2: Werk uw thema bij om de SDK te gebruiken

Dit codefragment biedt een startpunt voor de code die nodig is in uw thema om te integreren met de SDK:

/**
* This is just a demonstration of how theme licensing works with
* Easy Digital Downloads.
*
* @package EDD Sample Theme
*/

/**
* Load theme updater functions.
* Action is used so that child themes can easily disable.
*/

/**
* Initialize the theme license handler and updater.
*
* This registry handles activating and deactivating the license key,
* as well as checking for updates to the theme.
*/
add_action(
'edd_sl_sdk_registry',
function ( $init ) {
$init->register(
array(
'id' => 'edd-sample-theme',
'url' => 'https://edd.local',
'item_id' => 36894,
'version' => '1.0.0',
'file' => __FILE__,
'type' => 'theme',
)
);
}
);

// Load the SDK from the vendor directory. The SDK handles autoloader setup automatically.
if ( file_exists( __DIR__ . '/vendor/easy-digital-downloads/edd-sl-sdk/edd-sl-sdk.php' ) ) {
require_once __DIR__ . '/vendor/easy-digital-downloads/edd-sl-sdk/edd-sl-sdk.php';
}
}

Wijzig de informatie zodat deze overeenkomt met uw winkel:

  • id – Plugin/thema slug.
  • url – De winkel-URL.
  • item_id – De item-ID (in uw winkel).
  • version – Het huidige versienummer.
  • file – Het hoofdpluginbestand. Niet nodig voor thema's.
  • typeplugin of theme. Niet nodig voor plugins.
  • weekly_check – Optioneel: of er wekelijks een verzoek wordt gedaan om de licentiestatus te bevestigen. Standaard is dit waar.

Zodra uw thema is geactiveerd, kunnen uw klanten hun licentiesleutel toevoegen en zich aanmelden om uw winkel toe te staan hun PHP- en WordPress-versies toe te voegen aan hun activeringsgegevens:

Belangrijke opmerkingen

  • Als u problemen ondervindt met SSL-verificatie bij het aanvragen van updates, kunt u de filter edd_sl_api_request_verify_ssl gebruiken om het SSL-verificatievlag uit te schakelen.
  • Als u wilt voorkomen dat uw gebruikers automatische updates inschakelen voor uw thema of plugin, kunt u een codefragment toevoegen aan uw gedistribueerde code om automatische updates uit te schakelen:
add_filter( 'auto_update_plugin', 'edd_sample_disable_plugin_autoupdates', 10, 2 );
function edd_sample_disable_plugin_autoupdates( $update, $plugin ) {
	if ( 'my-plugin/my-plugin.php' === $plugin->plugin ) {
		return false;
	}

	return $update;
}

add_filter( 'auto_update_theme', 'edd_sample_disable_theme_autoupdates', 10, 2 );
function edd_sample_disable_theme_autoupdates( $update, $theme ) {
	if ( 'my-theme' === $theme->theme ) {
		return false;
	}

	return $update;
}
Was dit artikel nuttig?

Begin vandaag nog met verkopen!

Sluit u aan bij meer dan 50.000 slimme winkel eigenaren, en begin met de eenvoudigste manier om digitale producten te verkopen met WordPress.

Copyright © 2025 Sandhills Development, LLC

[universally_switcher]